server-api-putc

原型

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

1
2
3
4
5
6
7
8
9
// c:要写入的字符
// stream:要写入的文件流的指针
//
// return:
// 返回写入成功的字符,即参数c。若返回EOF则代表写入失败。
//
// 附加说明:
// putc()与fputc()作用相同,但putc()为宏定义,非真正的函数调用。
int putc(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){
putc(a[i], fp);
}

fclose(fp);
return 0;
}