Sunday, July 12, 2009

Help on file i/o reading these text file and printing it back in C....?

-0.000013828


-0.000014782


-0.000016689


-0.000018120


-0.000019550


.....


the numbers are placed as is in a text file...c:\\data.txt.....


I need to read them from file do some stuff and print the same number of numbers as shown above onto another text file...help please.

Help on file i/o reading these text file and printing it back in C....?
You'll need to open 2 files, one for writing and one for reading, use fopen() for this.





To read a line, use fgets().





You'll get these numbers as a string which is probably not what you want to "do some stuff". strtod() will convert them to doubles.





To write a line, use fprintf()





The compiler you're using or the internet will have complete documentation on these functions.





Hope this helps.....


No comments:

Post a Comment