C语言学习(34)
1 //fputs函数是把字符串写入指定文件中 2 #include<stdio.h> 3 #include<stdlib.h> 4 int main(){ 5 FILE *fp; 6 char str[20]; 7 if((fp=fopen("file_data.txt","w"))==NULL ){ 8 printf("打开文件失败\n"); 9 exit(0); 10 } 11 printf("请输入字符串:"); 12 gets(str); 13 fputs(str,fp); 14 fclose(fp); 15 return 0; 16 }
posted on 2018-06-28 17:22 孙悟空son_ku_kong 阅读(114) 评论(0) 编辑 收藏 举报