在 Mac 中是否有与 getch() 函数等效的函数?

3

我找不到在Mac上用于C程序的conio.h头文件的等效文件。

我想知道在Mac中是否有任何选项可以使用getch()函数

我希望用户可以提供选项并且程序将继续执行而无需按下回车键。


2
没有通用的解决方案,最简单的可能是使用ncurses或从https://dev59.com/MnRC5IYBdhLWcg3wD83r中选择其他建议之一。 - UnholySheep
1个回答

1

你可能想看一下ncurses。它与conio有很多共同之处。你可以通过"man ncurses"获取它的文档。


感谢您的建议。我尝试使用ncurses,但是它给了我以下错误:Undefined symbols for architecture x86_64: "_stdscr", referenced from: _main in test-54aaa4.o "_wgetch", referenced from: _main in test-54aaa4.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) - Gopal Srivastava
你是否已经链接了libncurses库?仅仅包含头文件是无法完成库链接的。 - Rob Napier
1
谢谢 Rob。现在它运行良好。我没有链接ncurses库。我使用-lncurses链接库,现在一切都很顺利。 - Gopal Srivastava

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接