File Handling : It  is a way of performing operation on file using C language. operations are  like creation of file, writing, appending, reading and etc.

here is code given below for creating and writing into that file. Enjoy 🙂



// function for creating and writing in file
void create_marks_csv(char *filename){
FILE *fp;
int i, count, id, micro, dcn, ds, rd;

printf("\n Creating %s.csv file",filename);


fprintf(fp,"Student Id, Microprocessor, RDMBMS, DCN, DS");
printf("How many student's marks do you want to save?");
scanf("%d", &count);

for(i = 1; i <= count; i++){
 printf("Enter student id");
 scanf("%d", &id);
 printf("Enter Microprocessor marks");
 scanf("%d", &micro);
 printf("Enter RDBMS marks");
 scanf("%d", &rd);
 printf("Enter DCN marks");
 scanf("%d", &dcn);
 printf("Enter DS marks");
 scanf("%d", &ds);


printf("\n %sfile created",filename);

//main method
int main(){
 char str[100];
 printf("\n Enter the filename :");


return 0;

Hope you guys liked it. please let me know if you need any help. Thanks 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *