#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc!=3)
{
printf("Not enough arguments... :P ");
exit(0);
}
char ch;
FILE *source, *dest;
source = fopen(argv[1], "r");
dest = fopen(argv[2], "w");
while( ( ch = fgetc(source) ) != EOF )
fputc(ch, dest);
printf("File copied successfully.\n");
fclose(source);
fclose(dest);
return 0;
}
TO RUN THE PROGRAM:
gcc program_name.c -o cpy
./cpy source_file_name dest_file_name
------------------------------------------------------------------------------------------------------------
#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;
}
TO RUN THE PROGRAM:
gcc program_name.c -o cpy
./cpy
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc!=3)
{
printf("Not enough arguments... :P ");
exit(0);
}
char ch;
FILE *source, *dest;
source = fopen(argv[1], "r");
dest = fopen(argv[2], "w");
while( ( ch = fgetc(source) ) != EOF )
fputc(ch, dest);
printf("File copied successfully.\n");
fclose(source);
fclose(dest);
return 0;
}
TO RUN THE PROGRAM:
gcc program_name.c -o cpy
./cpy source_file_name dest_file_name
------------------------------------------------------------------------------------------------------------
#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;
}
TO RUN THE PROGRAM:
gcc program_name.c -o cpy
./cpy
No comments:
Post a Comment