【问题标题】:Why do I get an error undefined reference to `getche'? [duplicate]为什么我得到一个错误 undefined reference to `getche'? [复制]
【发布时间】:2020-04-25 15:12:48
【问题描述】:

我在16.04.1-Ubuntu LTS 上使用clang-7。 我收到此警告:

warning: implicit declaration of function 'getche' is invalid in C99 
[-Wimplicit-function-declaration]

随后出现此错误:

error: undefined reference to 'getche'`

可能出了什么问题?

这是我的代码的链接:

https://repl.it/@kallyas/Employees-Record-System

【问题讨论】:

  • getche 不是我知道的标准函数,您自己也没有定义。你想调用什么函数?
  • getche 是 Microsoft 特有的函数,在您的编译环境中不存在。
  • getche() 获取用户输入的单个字符@DanielFarrell
  • 它是 Windows MSVC 中的一个扩展,需要 #include <conio.h>,但 MS 也弃用它以支持 _getche(),以遵循标准 C 规则来实现特定于实现的名称。但是,该功能仍受支持。

标签: c linux ubuntu


【解决方案1】:

getche()<conio.h> 库,因此它是特定于 Windows 的,您可以查看 What is the equivalent to getch() & getche() in Linux? 的替代方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多