C语言fputc()函数:写文件函数(将一指定字符写入文件流中)
头文件:
?| 1 |
#include <stdio.h>
|
定义函数:
?| 1 |
int fputc(int c, FILE * stream);
|
函数说明:fputc 会将参数c 转为unsigned char 后写入参数stream 指定的文件中.
返回值:fputc()会返回写入成功的字符, 即参数c. 若返回EOF 则代表写入失败.
范例
?| 1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include <stdio.h>
main()
{
FILE * fp;
char a[26] = "abcdefghijklmnopqrstuvwxyz";
int i;
fp = fopen("noexist", "w");
for(i = 0; i < 26; i++)
fputc(a[i], fp);
fclose(fp);
}
|
C语言fputs()函数:写文件函数(将一指定的字符串写入文件)
头文件:
?| 1 |
#include <stdio.h>
|
定义函数:
?| 1 |
int fputs(const char * s, FILE * stream);
|
函数说明:fputs()用来将参数s 所指的字符串写入到参数stream 所指的文件内.
返回值:若成功则返回写出的字符个数, 返回EOF 则表示有错误发生.








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。