Tuesday, July 12, 2011

simulate DOS 'copy' command in c

#include<stdio.h>
#include<stdlib.h>
int main()
{
char command[100],source[100],destination[100];
int ret;
printf("\nEnter the source file name ");
gets(source);
printf("\nEnter the destination file name ");
gets(destination);
sprintf(command,"cp %s %s",source,destination);
ret=system(command);
if(ret==0)
    printf("Successfully Copied from %s to %s\n",source,destination);
return 0;
}

No comments:

Post a Comment