#include"stdio.h"
main(int argc, char **argv)
{
FILE *s_ptr , *t_ptr;
char ch,c;
if(argc!=3)
{
printf("ERROR: Invalid no. of Arguments\n");
printf("Usage: copy \n");
return;
}
s_ptr = fopen(argv[1],"r");
if(s_ptr==NULL)
{
printf("Source File not Found\n");
return;
}
t_ptr = fopen(argv[2],"r+");
if(t_ptr==NULL)
{
printf("Target File not Found\n");
printf("Do you want to create it (Y/N):\n");
scanf(" %c",&ch);
if(ch=='y' || ch=='Y')
{
t_ptr = fopen(argv[2],"w");
while((c=fgetc(s_ptr))!=EOF)
fputc(c,t_ptr);
}
else
return;
}
fclose(s_ptr);
fclose(t_ptr);
}
main(int argc, char **argv)
{
FILE *s_ptr , *t_ptr;
char ch,c;
if(argc!=3)
{
printf("ERROR: Invalid no. of Arguments\n");
printf("Usage: copy
return;
}
s_ptr = fopen(argv[1],"r");
if(s_ptr==NULL)
{
printf("Source File not Found\n");
return;
}
t_ptr = fopen(argv[2],"r+");
if(t_ptr==NULL)
{
printf("Target File not Found\n");
printf("Do you want to create it (Y/N):\n");
scanf(" %c",&ch);
if(ch=='y' || ch=='Y')
{
t_ptr = fopen(argv[2],"w");
while((c=fgetc(s_ptr))!=EOF)
fputc(c,t_ptr);
}
else
return;
}
fclose(s_ptr);
fclose(t_ptr);
}
1 comment:
NIce One.....
Post a Comment