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 7589287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:07:22+00:00 2026-05-30T20:07:22+00:00

I have been struggling with this issue for one week, and still far away

  • 0

I have been struggling with this issue for one week, and still far away from the solution.

I am reading a plain text from a file by strings. It reads everything successfully until a character with a certain large number.
This number is specific for each file, and is different for different files.

After reaching the character with this large number, it reads “\x01\0\0\0” sequences (consist of 4 chars) for one or more times instead of the original characters, and then reads everything correctly (until the next large number).

In a couple of words – instead of reading this:

... many characters ...
First read failure!
... many characters ...
Second read failure, second read failure!
... many characters ...
etc.

it reads this:

... many characters ...
First read f\x01\0\0\0re
... many characters ...
Second read failu\x01\0\0\0\x01\0\0\0\x01\0\0\0ead failure!
... many characters ...
etc.

Do you have any ideas about the cause of this problem?

Additional information:

 1) The "ferror" condition is not true.
 2) I am reading from file using streams (fopen, fread, fclose)
 3) Have tested different read methods: "fread cycle" and "fgets".
    The results are the same.
 4) The binary optimization is disabled in the compiler's settings.
    It seams that the problem is not connected with a compiler.
    Neither GCC, nor Apple LLVM gives me the desired result.
 5) Attempting to solve the issue, I converted the whole project from C++ to C,
    but the problem doesn't disappear.
  • 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-30T20:07:23+00:00Added an answer on May 30, 2026 at 8:07 pm

    As I suggested in comments:

    • you should put your source code in the question (which you can always edit to improve it), not in comments
    • you should use POSIX 2008 getline function on your FILE*.
    • you should free the buffer implicitly malloc-ed by getline later, e.g. when fclose-ing your FILE* handle.
    • you should learn to use a debugger like gdb
    • you should learn to use a memory leakage detector like valgrind
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new with ruby and rails and have been struggling with this issue for
I've been struggling with this issue for a while now. I have OpenCart 1.5.2.1
I have been struggling with this yesterday whole day, and still couldnt figure it
I have been struggling with this issue for the past couple days: I have
I have been struggling with this issue for 3 hours. I know I can
I have been struggling with this NHibernate issue for hours. I extensively researched on
I have been struggling with this issue for a few hours now without understanding
I have been struggling with this issue for about 10 hours straight. I really
I am having this issue I have been struggling with for sometime and now
I have been struggling with this issue for some days now and I really

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.