enter 發表於 2015-3-6 18:53:45

scanf和gets的問題請教

本帖最後由 enter 於 2015-3-6 19:18 編輯

#include <stdio.h>

int main(void)
{
char file,str,*p,ch;
FILE *fp;
int i,j;

printf("Which file you want to write in?\n");
scanf("%s",file);

printf("Write the content:\n");
scanf("%s",str); //如果這裡是用 gets(str);則程式不會執行至此處,在印出Write the content:後就自動結束,為何?但如果上面也用gets(file);則這裡用gets(str);則ok。why?

return 0;
}
頁: [1]
查看完整版本: scanf和gets的問題請教