void test01() {
FILE* f_write = fopen("./text.txt","w+");
if (f_write == NULL) {
return;
}
char buf[] = "this is first test";
printf("%d", strlen(buf));
for (int i = 0; i < strlen(buf); ++i) {
fputc(buf[i],f_write);
}
fclose(f_write);
}
void test02() {
FILE* f_read = fopen("./text.txt", "r+");
if (f_read == NULL) {
return;
}
char ch;
while ((ch = fgetc(f_read))!=EOF) {
printf("%c", ch);
}
fclose(f_read);
}
文件读写fgetc()和fputc();
于 2023-12-27 13:25:41 首次发布