C语言从键盘输入字符串存储文本#作为结束符
代码:
#include <stdio.h> #include <string.h> #define N 1024 int main(int argc, char* argv[]) { FILE* fp; fp = fopen("file.txt", "w"); if(!fp){ printf("file open failed."); return 0; } char c; printf("please input a string end with #:\n"); c = getchar(); while(c != '#'){ fputc(c, fp); c = getchar(); } fclose(fp); return 0; }
长风破浪会有时,直挂云帆济沧海!
可通过下方链接找到博主
https://www.cnblogs.com/judes/p/10875138.html