server-api-fputc

原型

用于将一指定字符转为unsigned char后写入参数stream对应的文件中。

1
2
3
4
5
6
// c:要写入的字符
// stream:要写入的文件流的指针
//
// return:
// 返回写入成功的字符,即参数c。若返回EOF则代表写入失败。
int fputc(int c, FILE * stream);

使用参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>

int main()
{
FILE * fp;
char a[26]="abcdefghijklmnopqrstuvwxyz";
int i;

fp = fopen("test2", "w");
for(i = 0; i < 26; ++i){
fputc(a[i], fp);
}

fclose(fp);
return 0;
}