Do you have any idea why the above program is printing garbage for the age.
Type: Posts; User: theprogrammer
Do you have any idea why the above program is printing garbage for the age.
Actually they do exist. The second one allows you to read strings with spaces using scanf, the first allows you to ignore the newline before an integer.
I did try it without them though and it...
I am reading from a file. and I did use fflush(filename) and it did not work.
the following code won't work properly. it is supposed to read a name and an age. print them to a file. read them back from the file and print them on the screen
it prints the name from the file...
The reason for the while loop is to clean out the input stream as suggested in the faq instead of using fflush(stdin) however I removed them and the code still works.
Thanks a lot to everyone...
I read the faq's that vart suggested on fflush, feof, and fgets. I made the necessary changes I also am now reading in binary mode. the only effect now is that it is ony printing three characters...
it should be &data[i] and not *data[i] * I had changed it while attempting to debug the program. program seems to be fine. if I make all thee arrays sizes small. but gives problems when the array...
Anyone knows why this code isn't working. the problem seems to be related to the size of the char arrays.
I am trying to read some data into a struct, write the struct to a file, close the file,...
I am going to try that in a little while and let u know how it worked out.
I am writing a program that refuses to work. I use fwrite to write the struct to a file in main. Everything seems to write properly. However I can't seem to read the info back from the file properly....