Write a program to create a text file.
#include<stdio.h> int Crate_file(char*); enum File_Status{SUCCESS,FAIL}; int main() { char fileName[32]; printf("Enter file Name that you want to create= "); scanf("%[^\n]",fileName); if(SUCCESS == Create_file(fileName)) printf("File is successfully created\n"); else printf("File is not created\n"); return 0; } int Create_file(char* p) { FILE *fp; fp = fopen(p,"w"); if(fp == NULL) return FAIL; else return SUCCESS; }
Output
Enter file Name that you want to create= easy File is successfully created
ls easy easy