belongs to collection: File handling in C
create a file using fopen in C
In the below code, I am creating a text file using the fopen() function.
#include <stdio.h> #include <stdlib.h> int main() { FILE *fp = NULL; //create a text file fp = fopen ("aticleworld.txt", "w"); if(fp == NULL) { printf("File is not created\n"); exit(1); } else { printf("File is created\n"); } //close the file fclose(fp); return 0; }
Output:
If fopen() create file successfully, the text file will be created in the same folder where you have saved your code. Like the below image.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
In the below code, I am creating a text file using the fopen() function.
Output:
If fopen() create file successfully, the text file will be created in the same folder where you have saved your code. Like the below image.
need an explanation for this answer? contact us directly to get an explanation for this answer