代码:
#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;
}
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/161822.html