How To Make A File
Let's See How We Can Do It:-
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
FILE *fp;
char s[100];
clrscr();
fp=fopen("File.txt","w");
if(fp==NULL)
{
printf("file cannot open");
exit(0);
}
printf("Enter your name");
gets(s);
while(strlen(s)!=0)
{
fputs(s,fp);
printf("enter the string\n");
gets(s);
}
fclose(fp);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
FILE *fp;
char s[100];
clrscr();
fp=fopen("File.txt","w");
if(fp==NULL)
{
printf("file cannot open");
exit(0);
}
printf("Enter your name");
gets(s);
while(strlen(s)!=0)
{
fputs(s,fp);
printf("enter the string\n");
gets(s);
}
fclose(fp);
getch();
}
It's very helpful
ReplyDeleteYou explained very well...
ReplyDelete