将字符串写入文件
#include <stdio.h>
#include <stdlib.h>
int main()
{
char sentence[1000];
FILE *fptr;
fptr=fopen("runoob.txt","w");
if(fptr==NULL)
{
printf("error");
exit(1);
}
printf("输入字符串:\n");
fgets(sentence, (sizeof sentence / sizeof sentence[0]), stdin);
fprintf(fptr,"%s", sentence);
fclose(fptr);
return 0;
}
标签:fptr,文件,sentence,写入,printf,字符串,sizeof
From: https://www.cnblogs.com/yesiming/p/17471813.html