Okay,
I think I've sort of got it into memory now but there are still problems. When I try to print out the file that I've just got, it only gives me the last row.
And then I try to change a character and write the whole file back. However this just erases the original documnet.
Here is the code
Code:
int main()
{
// Read file into memory
FILE *in = fopen("file_to_edit", "r");
for (i=0; i<3; i++)
{
fgets(filename, SIZE, in);
printf( "got this from document: %s\n", filename);
}
fclose(in);
// Print out what i got
for (i=0; i<21; i++)
{
printf("%c", filename[i]);
}
// Change a value and store back into document
FILE *in2 = fopen("file_to_edit", "w");
filename[7] = 9;
for(i = 0; i<10; i++);
{
fprintf(in2,"%c\n",filename[i]);
}
fclose(in2);
return(0);
}
I'm sure the problems are more than obvious to your average programmer, however I'm still a newbie so any help is appreciated.
OJ