通过本文主要向大家介绍了fputs fputc,c语言fputs函数,c语言fputs函数用法,c语言fputs,c语言fputs用法等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
C语言fputc()函数:写文件函数(将一指定字符写入文件流中)
头文件:
#include <stdio.h></div>
定义函数:
int fputc(int c, FILE * stream);</div>
函数说明:fputc 会将参数c 转为unsigned char 后写入参数stream 指定的文件中.
返回值:fputc()会返回写入成功的字符, 即参数c. 若返回EOF 则代表写入失败.
范例
#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); }</div>
C语言fputs()函数:写文件函数(将一指定的字符串写入文件)
头文件:
#include <stdio.h></div>
定义函数:
int fputs(const char * s, FILE * stream);</div>
函数说明:fputs()用来将参数s 所指的字符串写入到参数stream 所指的文件内.
返回值:若成功则返回写出的字符个数, 返回EOF 则表示有错误发生.