C/C-- parsing data from file
Expert: Narendra - 3/16/2006
QuestionDear Narendra,
I am started in C program. I have to do a program which read and write data from a file and should be saved in a array for manipulation. So can u gimme an example program which read & write in file, also storing the value of data in array. please reply me..
thanx in advance
regards,
suresh
AnswerInstead of trying to get readymade programs (spoon feeding), try to study the book and trying out yourself.
First of all, find out what are the API's that are used for this.
You will need an API to open the file - fopen().
To read the file - fread() or fscanf() or fgets() or fgetc().
To write to file - fwrite(0 or fprintf() or fputs() or fputc().
To find the position in the file - ftell().
To go to any place in the file - fseek().
To close the file - fclose().
So, you have to learn all these API's and then start writing the sample code. Start studying the man pages for these and you will soon become an expert in these.