[問題] (已解決) VS 2012 C++ printf_s 字串

看板C_and_CPP (C/C++)作者 (Darren)時間10年前 (2015/12/08 15:38), 10年前編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VS 2012 C++ 問題(Question): #include <stdio.h> #include <stdlib.h> int main() { char c[10]; scanf_s("%s", c); system("PAUSE"); return 0; } 錯誤結果(Wrong Output): 但是編譯後執行 只要輸入字串就會出現以下畫面 http://tinyurl.com/gl92om7 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.231.121.220 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1449560312.A.8A0.html

12/08 15:41, , 1F
scanf_s 的 %s 還要另外傳入buffer的size
12/08 15:41, 1F

12/08 15:41, , 2F
scanf_s("%s", c, sizeof(c))
12/08 15:41, 2F
原來是這樣!! 感謝!! ※ 編輯: darrenliuptt (36.231.121.220), 12/08/2015 15:43:26 ※ 編輯: darrenliuptt (36.231.121.220), 12/08/2015 15:43:49
文章代碼(AID): #1MPeZuYW (C_and_CPP)
文章代碼(AID): #1MPeZuYW (C_and_CPP)