I have a program that reads a file, then writes thhe contents to another file, but I keep getting this stupid ÿ thing at the end of the output file. Any ideas?
Here's my code
#include <stdio.h>
int main()
{
char ifilename[] = "i:/emplistin.txt";
char ofilename[] = "i:/emplistout.txt";
char name;
char ch;
FILE *ofp, *ifp;
{
/* Open file for input */
ifp = fopen(ifilename,"r");
/* Open file for output */
ofp = fopen(ofilename,"w");
while (ch != EOF)
{
/* Read data */
ch = fgetc(ifp);
/* Write out data */
fputc(ch, ofp);
}
/* Close Files */
fclose(ifp);
fclose(ofp);
}
printf("hit enter to end program");
getchar(ch);
return 0;
}
Here's my code
#include <stdio.h>
int main()
{
char ifilename[] = "i:/emplistin.txt";
char ofilename[] = "i:/emplistout.txt";
char name;
char ch;
FILE *ofp, *ifp;
{
/* Open file for input */
ifp = fopen(ifilename,"r");
/* Open file for output */
ofp = fopen(ofilename,"w");
while (ch != EOF)
{
/* Read data */
ch = fgetc(ifp);
/* Write out data */
fputc(ch, ofp);
}
/* Close Files */
fclose(ifp);
fclose(ofp);
}
printf("hit enter to end program");
getchar(ch);
return 0;
}