Hi, well I was trying to write a simple, small program that copy files.
The code is this:
Code:
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc < 3)
{
printf("Not enought arguments supplied.");
exit(1);
}
FILE* f1;
FILE* f2;
f1=fopen(argv[1],"r");
if(f1==NULL)
{
printf("Source file does not exist.");
exit(1);
}
f2=fopen(argv[2],"w");
while(!feof(f1))
{
putc(getc(f1),f2);
}
fclose(f1);
fclose(f2);
return 0;
}
But when I copy the files some random chars get added at the end of the destination file.
Anyone knows what's wrong?
Oh, another question: What's the library for exit()?