#include
#include
#include
void main()
{
FILE* fp;
char ch, filename[20];
printf("Please input the filename you want write:\n");
scanf_s("%s", &filename);
if (fopen(filename,"wt+")==NULL)
{
printf("cannot open the file!\n");
exit(0);
}
fp = fopen(filename, "wt+");
printf("Please input the sentence you want write:\n");
ch = getchar();
ch = getchar();
while (ch != EOF)
{
fputc(ch, fp);
ch = getchar();
}
fclose(fp);
}
警告 C6054 可能没有为字符串“filename”添加字符串零终止符。 ConsoleApplication1 D:\PROJECT\PROJECT5\CONSOLEAPPLICATION1\CONSOLEAPPLICATION1.CPP 26
这个弄不懂怎么解决..