look at my different code below
Code:
#include<stdio.h>
int main()
{
FILE *fp;
char s[80];
int loop = 0;
fp = fopen("Text.txt","w");
printf("\nEnter a few lines of text:\n");
while(strlen(fgets(s,79,stdin)) > 0)
fputs(s,fp);
fclose(fp);
}
it cant working, when used 'while' but if i dont use 'while' like this
i mean not any string recorded on the Text.txt
if didnt using while, (so i can only writing at least one sentence as its equal to buffering size)
Code:
#include<stdio.h>
int main()
{
FILE *fp;
char s[80];
int loop = 0;
fp = fopen("Text.txt","w");
printf("\nEnter a few lines of text:\n");
fgets(s,79,stdin);
fputs(s,fp);
fclose(fp);
}
the string i write on the .c is recorded in the Text.txt
i wonder why?