C语言 创建一个 txt 文件 bin输入字符 保存文件在工作文件夹里

int main(void)

{
char s[70];
FILE *fp;
fp=fopen("123.txt","r");

if((fp=fopen("123.txt","w"))==NULL) //if 语句就是创建了一个空的.txt文件
{


printf("Open the file failure... ");
exit(0);
}
while(1)
{
printf("Input a string... s=");
if(gets(s),strlen(s)<70)
break;
printf("Too long, redo: ");
}
fputs(s,fp);

fclose(fp);
printf(" ");
return 0;
}

原文地址:https://www.cnblogs.com/locean/p/5279284.html