Here we gave easiest understanding program to you.
All programs easy to learn every person.
And all subjects are compulsory in BCA.
Powered by Blogger.

Followers

Tuesday, 17 September 2019

File operations in C program

0 comments

/* C Program to read data from keyword and store into a file xyz.txt*/




#include<stdio.h>
int main()
{

FILE *fp;

char ch;
fp=fopen("abc.txt","w");
if(fp==NULL)
{
printf("File opening error...");
return 0;
}
printf("Enter your data:\n");
while((ch=getchar())!=EOF)
{
fputc(ch,fp);
}
printf("Data stored sucessfully...");
fclose(fp);
return 0;
}


INPUT/OUTPUT:

Enter your data:
this is a sample file
^Z
Data stored sucessfully...
Content of xyz.txt file:
this is a sample file

No comments:

Post a Comment