I wrote a small program using C to copy the contents of one file into another. The problem is that it also copies an extra chracter at the end. The character is "ÿ". Any ideas on how I can solve this? I just want to have a simple program for file copy using stdio.h. Here is the code:
#include <stdio.h>
int main() {
FILE * inFile, * outFile;
inFile = fopen("c:\\in_test.txt","r");
outFile = fopen("c:\\out_test.txt","w");
// Copy each character from source
// till destination until end of file
while (!feof(inFile))
fputc(fgetc(inFile), outFile);
// Close files and return
fclose(outFile);
fclose(inFile);
return 0;
}
#include <stdio.h>
int main() {
FILE * inFile, * outFile;
inFile = fopen("c:\\in_test.txt","r");
outFile = fopen("c:\\out_test.txt","w");
// Copy each character from source
// till destination until end of file
while (!feof(inFile))
fputc(fgetc(inFile), outFile);
// Close files and return
fclose(outFile);
fclose(inFile);
return 0;
}