How to Create File in C Programming

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

//Program for create file in C Language
#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp=NULL;
    char ch;
    fp=fopen("e://cdata/employee.txt","w");
    if(fp==NULL)
    printf("File not created.........");
    else
    {
        printf("\nEnter a String: ");
       while(1)
       { 
           ch=getche();
           if(ch=='0') break;
           fputc(ch,fp);
       } 
        printf("\n File created........");
        fclose(fp);
    }
}

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

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