[問題] 有關getche()將字元轉成字串...
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev-c
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
為什麼getche()接收的字元集合 != 字串呢??
餵入的資料(Input):
#define Enter 13
char ch;
char str[10];
int i=0
printf("請輸入一個字串: ");
if ((ch=getche())!=Enter)
str[i++]=ch; //假設輸入一個小於10個字元的字串,ex: 12345
puts(str)= 亂碼?? 而不是等於12345????
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.141.245.232
→
08/16 15:34, , 1F
08/16 15:34, 1F
→
08/16 15:35, , 2F
08/16 15:35, 2F
→
08/16 15:38, , 3F
08/16 15:38, 3F
→
08/16 15:40, , 4F
08/16 15:40, 4F
→
08/16 17:27, , 5F
08/16 17:27, 5F
→
08/16 19:12, , 6F
08/16 19:12, 6F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章