| Simple File Management | Using Command Line Argument |
| #include "stdio.h" #include "conio.h" #include "stdlib.h" void main() { FILE *fp1,*fp2; char ch; clrscr(); //Open File 1 in Read Mode fp1=fopen(“D:\abc.txt”,"r"); //Open File 2 in Write Mode fp2=fopen(“D:\xyz.txt”,"w"); //Read data from File 1 ch=getc(fp1); while(ch!=EOF) { printf("%c",ch); //Write data to File 2 putc(ch,fp2); //Read data From File 1 ch=getc(fp1); } fclose(fp); fclose(fp1); getch(); } | #include "stdio.h" #include "conio.h" #include "stdlib.h" void main(int argc,char *argv[]) { FILE *fp1,*fp2; char ch; clrscr(); //Open File 1 in Read Mode fp1=fopen(argv[1],"r"); //Open File 2 in Write Mode fp2=fopen(argv[2],"w"); //Read data from File 1 ch=getc(fp1); while(ch!=EOF) { printf("%c",ch); //Write data to File 2 putc(ch,fp2); //Read data From File 1 ch=getc(fp1); } fclose(fp); fclose(fp1); getch(); } |
GTU MCA Practical Solution for C ,C++, java, DBMS, SQL, RMI, CORBA, Network Programming, Servlet, JSP, ASP Code.