C 语言实例 - 将字符串写入文件
C 语言教程
· 2019-02-21 11:11:24
将字符串写入文件。
实例
#include <stdio.h>
#include <stdlib.h> /* exit() 函数 */
int main()
{
char sentence[1000];
FILE *fptr;
fptr = fopen("codercto.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;
}
输出结果为:
输入字符串: codercto.com
打开文件 codercto.txt:
$ cat codercto.txt codercto.com
点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html
ActionScript 3.0 Cookbook
Joey Lott、Darron Schall、Keith Peters / Adobe Dev Library / 2006-10-11 / GBP 28.50
Well before Ajax and Microsoft's Windows Presentation Foundation hit the scene, Macromedia offered the first method for building web pages with the responsiveness and functionality of desktop programs......一起来看看 《ActionScript 3.0 Cookbook》 这本书的介绍吧!