Hi,
the concept of the program is enter a piece of text from the keyboard and place that piece of text into a file
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
FILE *fp;
char s[80];
fp=fopen("new.txt","w");
if(fp==NULL)
{
printf("unable to open file");
exit(1);
}
printf("enter new line of text:\n");
while(strlen(gets(s))>0)
{
fputs(s, fp);
fputs("\n", fp);
}
fclose(fp);
}
But, after completing this program
when I open the text file there is no result at all
what is the problem is it really write the contents to a new.txt file or not. If yes please explain briefly why my text file is not changin
else please give the solution
regards,