Hi, guys. I am having problem with my FILE input.
Whenever I input a structured data into my FILE, my first record displays correctly. But the subsequent entries contain the left over characters from the previous input.
Say for e.g. I entered a title for a book as:
Teach Yourself C Programming (first record)
If I enter a second record, e.g with the input
'C Language for Dummies' I will get the result below
in my FILE:
C Language for Dummiesmming
Seems to me that the first record has some leftover characters which was not removed. I have tried using fflush(), flushall(), fgets() but to no avail.
My Question is: Is there any way to rectify this problem?
The funny thing is, when I display/view specific records, the data extracted was correct (i.e. without the leftover characters). It is only when I open the FILE (text file) with notepad that I see the leftover characters in the data.
For your info, I am using gets() to input my strings.
Thanks in advance,
Darryl H
Whenever I input a structured data into my FILE, my first record displays correctly. But the subsequent entries contain the left over characters from the previous input.
Say for e.g. I entered a title for a book as:
Teach Yourself C Programming (first record)
If I enter a second record, e.g with the input
'C Language for Dummies' I will get the result below
in my FILE:
C Language for Dummiesmming
Seems to me that the first record has some leftover characters which was not removed. I have tried using fflush(), flushall(), fgets() but to no avail.
My Question is: Is there any way to rectify this problem?
The funny thing is, when I display/view specific records, the data extracted was correct (i.e. without the leftover characters). It is only when I open the FILE (text file) with notepad that I see the leftover characters in the data.
For your info, I am using gets() to input my strings.
Thanks in advance,
Darryl H