code.club

 找回密碼
 立即註冊
搜索
查看: 5928|回復: 0
打印 上一主題 下一主題

scanf和gets的問題請教

[複製鏈接]
跳轉到指定樓層
樓主
發表於 2015-3-6 18:53:45 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
本帖最後由 enter 於 2015-3-6 19:18 編輯

#include <stdio.h>

int main(void)
{
char file[20],str[300],*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;
}
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

小黑屋|手機版|Archiver|code.club  

GMT+8, 2024-4-27 20:39 , Processed in 0.102556 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表