#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
FILE* fp = fopen("test.txt", "w+");
if (!fp) {
perror("fopen error");
return -1;
}
char m = 0;
while (1) {
scanf("%c",&m);
if (m == ':') //:结束写操作
{
break;
}
fputc(m,fp);
fflush(fp);//刷新缓冲区(写到硬盘)如果不加fflush要fclose时才在硬盘显示
}
fclose(fp);//关闭时刷新缓冲区(写到硬盘)
system("pause");
return EXIT_SUCCESS;
}
07-24
792
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-31