int main()
{
FILE *file1, *file2;
char filename[] = "test.xml";
char c;
int line = 1;
//open file in read mode
file1 = fopen(filename, "r");
c = getc(file1);
while (c != EOF){
printf("%c", c);
c = getc(file1);
}
//rewind
rewind(file1);
//fseek(file1, 0, SEEK_SET);
//open new file in write mode
file2 = fopen("replica.c", "w");
c = getc(file1);
if(c == EOF) printf("toto");
}
The rewind() and fseek() functions don't work, my program display "toto", so file1 is still positioned on EOF.
Do you have an idea to solve this probleme please?