看板 LinuxDev 關於我們 聯絡資訊
不好意斯我是linux與 C的新手 請問一下每次用vim打C的程式碼 用到getch()之纇的 都會在編譯時發生 undefined reference to 'getch' 但是我都有的在開頭使用 #include<stdio.h> 等之纇的 依然還是找不到 用gcc -lm -L/usr/lib -L/lib 與 -lm -I/usr/include 依然不能編譯 請問一下到底哪出了問題 能否幫我解答一下 困擾我很久了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.64.145.209
smallbug02:stdio.h好像只有getc 跟 getchar 有getch這個函式嗎@@ 12/11 11:54
smallbug02:-lm 應該是你有include math.h才需要用吧? 12/11 11:56
forlaster:因為我照書打的我也不太知道 書中還有puts()gets() 12/11 12:06
forlaster:也都找不到 所以就問了 12/11 12:07
forlaster:原來-lm 後面還要接檔名呀 不是自行去找那下面的函式庫 12/11 12:08
noonOut:getch好像是MS版本的C才有吧...我記得我以前遇過類似問題 12/11 14:53
jtmh:curses/ncurses 函式庫中有 getch() 可以用。 12/11 16:06
fumin:書中附錄應該會有註明哪些function是ANSI C,哪些不是 12/17 00:37