【发布时间】:2018-04-14 02:13:14
【问题描述】:
我正在尝试使用 curses.h 从键盘获取字符。 这是我的来源(get_char_example.c):
#include <curses.h>
#include <stdio.h>
int main(void)
{
char ch;
printf("Enter a character: ");
ch = getch();
printf("\nIts ASCII code is %d\n", ch);
return 0;
}
我使用如下命令编译:
gcc get_char_example.c -o get_char_example
我收到以下错误:
/tmp/ccjaXwRU.o:在函数'main'中:
get_char_example.c:(.text+0x1c): undefined reference to `stdscr'
get_char_example.c:(.text+0x24): undefined reference to `wgetch'
collect2: error: ld returned 1 exit status
使用:gcc (GCC) 7.2.0 Arch Linux 4.13.9-1-ARCH
提前致谢!
【问题讨论】:
-
我相信它不是重复的。然而,这个问题确实缺乏研究工作。