#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
int i;
char *str = "longhaiyang heng ai sasa";
int len = strlen(str);
fp = fopen("./test","w+");
for(i=0;i<len;i++)
{
fputc(*str,fp); //fputc('a',fp);
str++;
}
fclose(fp);
return 0;
}
#include <stdio.h>
#include <string.h>
//fgetc feof
int main()
{
FILE *fp;
int i;
char c;
fp = fopen("./test.txt","r");
while(!feof(fp)){ //feof()用来判断是否到了文件末尾 没到返回0 到了返回非0
c = fgetc(fp);
printf("%c",c);
}
fclose(fp);
return 0;
}```
Linux文件编程demo13文件其他函数讲解及文件收尾.c
最新推荐文章于 2025-12-06 19:52:12 发布
960

被折叠的 条评论
为什么被折叠?



