C program to open a file and write some text and close its.
source code
#include<stdio.h>
int main()
{
FILE *fp;
char ch;
fp=fopen("file.txt","w");
printf("\nEnter data to be stored in to the file:");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
getch();
return 0;
}
Comments
Post a Comment