📅  最后修改于: 2020-10-22 08:27:50             🧑  作者: Mango
fputc()函数用于将单个字符写入文件。它将字符输出到流。
句法:
int fputc(int c, FILE *stream)
例:
#include
main(){
FILE *fp;
fp = fopen("file1.txt", "w");//opening file
fputc('a',fp);//writing single character into file
fclose(fp);//closing file
}
file1.txt
a
fgetc()函数从文件返回单个字符。它从流中获取一个字符。它在文件末尾返回EOF。
句法:
int fgetc(FILE *stream)
例:
#include
#include
void main(){
FILE *fp;
char c;
clrscr();
fp=fopen("myfile.txt","r");
while((c=fgetc(fp))!=EOF){
printf("%c",c);
}
fclose(fp);
getch();
}
myfile.txt
this is simple text message