1 /*A C PRORAM TO USE low level file operations/...fopen...fgetc...fputc...fclose*/
2 #include<stdio.h>
3 #include<stdlib.h>
4 int main()
5 {
6 char ch,sor[10],tar[10];
7 FILE *fd,*wfd;
8 gets(sor);
9 puts(sor);
10 fd=fopen("anu","r");//there are 2 arguments to open the file using fopen...1st is name of f ile that is to be open....& 2nd is mode in which file is to open...//
11 gets(tar);
12 puts(tar);
13 wfd=fopen("dest","w");//again fopen is used...//
14 ch=fgetc(fd);//once read one character from the file...fgetc has only 1 argument..that file descriptor of FILE type pointer...fgetc takes fd as argument & return characer value...//
15 printf("ch=%c\n",ch);//print if character value is correct..//
16 fputc(ch,wfd);//fputc has 2 arguments...//..1st one is character which is to be put in file which is open in write only mode...&...another is file descriptor of FILE type...//
17 while((ch=fgetc(fd)) != EOF)//in the same way ..read each & every character from descriptor of file & in while loop write that character into ch into wfd descriptor...//
18 {
19 fputc(ch,wfd);
20 printf("ch=%c\n",ch);
21 //sleep(1);
22
23 }
24 fclose(fd);//close the descriptors using fclose