File handling in C Programming Simple Example
Here, you will get a program of file handling in C programming examples to create a ms-excel file using files in c. In this program first we will create an excel file using file handling, then write data in file, after that read data from file and print on the output screen.
File handling in C Programming Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include<stdio.h> #include<conio.h> //*******************create excel file and print data*********************** main() { char ch; FILE *fp; fp=fopen("test.xls","w"); printf("Enter data for writing into file(end the data by input '$' sign :"); //input data into file while(ch!='$') { scanf("%c",&ch); fputc(ch,fp); } fclose(fp); fp=fopen("test.xls","r"); ch=' '; //printing data from file while(ch!='$') { ch=fgetc(fp); printf("%c",ch); } fclose(fp); getch(); } |
Output
Check out our other C programming Examples