hi everyone,
the below program is yielding error "segmentation fault",when it is run under unix. This is a file copy program using command line arguements.
Without using command line arguement,i mean,taking filenames directly in the program runs successfully. Can anyone tell me what
"segmentation fault" means in unix?
-------------------
#include<stdio.h>
int main(int argc,char *argv[])
{
FILE *fp,*ft;
char ch;
if(argc!=3)
{
printf("error");
exit();
}
fp=fopen("argv[1]","rb");
ft=fopen("argv[2]","wb");
while(!feof(fp))
{
ch=fgetc(fp);
fputc(ch,ft);
}
fclose(fp);
fclose(ft);
return 0;
}