Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 530077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:09:31+00:00 2026-05-13T09:09:31+00:00

I am reading in a file with a format similar to: TIME, x, y,

  • 0

I am reading in a file with a format similar to:

TIME, x, y, z
00:00:00.000 , 1, 2 , 3
00:00:00.001 , 2 , 3 , 4

etc, and code similar to the following:

std::ifstream& istream;
char buffer[15];
double seconds, hours, mins; // initialised properly in real code

// to read in first column
istream.get(buffer, 14, ',');

int scanned = std::sscanf(buffer, "%d:%d:%lf", &hours, &mins, &seconds);

It reads in the first column fine for most of the time. However, occasionally the sscanf fails, and when I check what is in the buffer using the Codegear debugger I see that it has read in \000:00:023 for example. For some reason it is collecting a null character ,\0, at the front. When I look in the text file, it appears to be the same format as all the other time values that were read in correctly. Why is it occasionally adding a null character? And is there a work around?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:09:31+00:00Added an answer on May 13, 2026 at 9:09 am

    You have read a blank line, or you are trying to read past the end of the file.

    The first character is \0, which signifies the end of the string.

    Any characters after that are untouched memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this tutorial to read the xlsx file format. I'm reading xlsx file.
My Python code supports reading and writing data in a file format created by
I have a file in .gz format. The java class for reading this file
Hey all. I'm reading from one sql-format file to another, and two bytes in
I am reading from file of format 1 32 43 23 32 43 123
I'm reading Propellerheads' NN-XT file-format, but I'm having problems with the REFE chunk. The
I have custom model file format that I am reading from to create a
I'm using code that someone else wrote to load a file format that I
In particular, I'm reading into the Mach-O binary file format for Intel 32 on
How would you go about reading a simple file format using C or C++?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.