- 博客(7)
- 收藏
- 关注
翻译 C语言——fprintf
fprintf往文件中写格式化数据 函数原型 #include<stdio.h> int fprintf(FILE *stream,const char *format,...); 实例 #include<stdio.h> /* *需求:让用户输入学员的姓名、年龄 并把这些信息按照如下格式保存到文件students.txt 姓名:张飞 年龄:38 姓名...
2019-01-24 11:41:45
1626
翻译 C语言——fputs用法
fputs写一个字符串到文件中去 函数原型 #include<stdio.h> int fputs(const char *str,FILE *stream); #include<stdio.h> /* *需求:把文件test.c拷贝到新文件test_copy.c中, 本文件为test.c */ int main (void) { FILE * file1; ...
2019-01-23 12:03:54
3752
1
翻译 C语言——fgets
fgets从文件中读取一个字符串 函数原型 #xinclude<stdio.h> char* fgets(char*str, int num, FILE*stream); 参数 num:最多读取num-1个字符,或者遇到文件结束符EOF为止(即“文件读完了”) 返回值 读取失败时,返回NIULL,读取成功时返回str #include<stdio.h> /* *需求:打印...
2019-01-22 19:26:16
558
翻译 C语言——fputc
fputc写一个字符到文件中去 函数原型 #include<stdio.h> int fputc(int ch,FILE*stream); 实例 /*需求:把这个源程序代码,复制到另一个文件 *使用fputc实现 */ #include<stdio.h> int main(void){ FILE * file1; FILE * file2; char c; //打...
2019-01-22 18:09:27
936
翻译 C语言——fgets用法
** fgetc文件的读操作 ** 函数原型 #include<stdio.h> int fgetc(FILE*stream); 返回值:成功时返回读到的字符,返回的是int类型(实际值时字符)失败或读到文件尾,返回EOF(就是-1) 作用:从文件中读取一个字符 实例: #include<stdio.h> /** *需求:把这个文件的源代码打印输出(test.c) */ ...
2019-01-22 16:22:27
771
1
翻译 C语言——fclose用法
#include<stdio.h> int main(void){ FILE * flie file = fopen("user.txt","a"); if (! file){ printf("文件打开失败!"); } fputs("\n刘备 abc123",file); system("pause");
2019-01-22 16:01:05
1247
翻译 C语言——fopen用法
** fopen文件的打开操作 ** 函数原型 #include<stdio.h> FILE*fopen(const char*fname,const char*mode); 参数1:fname表示文件名(可以包含文件路径) 参数2:打开方式 返回值:FILE*文件指针,如果打开失败,返回NULL(就是0) mode打开方式 “r”——以“读”的方式打开一个文本文件(只能读) “r+...
2019-01-22 15:45:03
2351
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人