fputc
#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp;
int i;
char *str = "chenlichen bu shuai?";
int strLen = strlen(str);
fp = fopen("./test.txt","w+");
for(i=0;i<strLen;i++){
fputc(*str,fp);
str++;
}
fclose(fp);
return 0;
}
文件/test.txt中
chenlichen bu shuai?
fgetc和feof
#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp;
char c;
fp = fopen("./test.txt","r");
while(!feof(fp)){
c = fgetc(fp);
printf("%c",c);
}
fclose(fp);
return 0;
}
Linux一切皆文件 文件系统(文件夹 /文件 ) 硬件设备 管道 数据库 Socket等