第1个回答 2015-12-23
#include <stdio.h>
#include <string.h>
#define STR_LEN 512
int main(void)
{
char str[STR_LEN];
FILE *fp;
fp=fopen("test.bat","wb");
if(NULL==fp)
{
printf("创建或打开文件失败!\n");d
exit(0);
}
scanf("%s",&str);
fprintf(fp,"%s\n",str);
fclose(fp);
getch();
return 0;
}本回答被网友采纳