Can anyone help? For some reason this code won't work. The file remains unchanged.
Code:#include <stdio.h>
int main ()
{
FILE *f1;
int ch;
f1 = fopen("file2.txt", "r+");
if (f1 == NULL)
{
printf("File access error.\n");
return;
}
while((ch = fgetc(f1)) != EOF)
{
if (ch == '\n')
fputc('\n', f1);
}
printf("File processing complete.\n");
if (fclose(f1) != 0)
printf("File close error.\n");
return 0;
}