Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
The next bug is at line 15 -- feof() doesn't work the way you think. Instead, you should code it like this (which will only work with text files. binary files are coded differently because the EOF character could be a valid character in the file.):
while( (ch=fgetc(fp)) != EOF)
{
fputc(ch,ft);
}
Another bug: failing to check that the two files were successfully opened. If the source file in argv[1] doesn't exist then no point attempting go open the output file and copy. And if the output file can not be created pointerft will be NULL and the copy loop will fail causing segment violation.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343