c - 我的程序(获取函数)有什么问题?

标签 c

我正在学习 C 编程语言,在进行一些练习时,我遇到了有关 getch() 函数的错误!

这是我的代码:

    #include <stdio.h>
#include <stdlib.h>

int main(){
    int size = 6;
    int markers[size];
    int counter;

    for (counter = 0; counter < size; counter++){
        scanf("%d",&markers[counter]);
    }

    for (counter=0; counter < size; counter++){
        printf("The element at %d is %d\n",counter,markers[counter]);
    }
    getch();
    return 0;
}

最佳答案

getch()不是 ANSI C 函数。您需要包含头文件 <conio.h>使用它。或者最重要的是,只需使用符合 ANSI 的函数 getchar() .

关于c - 我的程序(获取函数)有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35242061/

相关文章:

C,结构中的枚举,错误C2016,头文件

c - 有没有一种特殊的方法可以从 c 中的文件中删除记录而不创建它的副本?

c - Windows 上 C/GTK 应用程序的简单更新机制

c - 得到一个奇数,太奇怪了

c - Swift无法从linphone sdk中的c回调中调用自己

将无符号整数 (uint16_t) 转换为字符串。标准 itoa base 10 给出负值

c++ - 如何从 C/C++ 在 Linux 中设置 IRQ 优先级?

c# - 具有显式(手动)字段布局的 C 结构/union ?

c - 不同 C 编译器输出的歧义

c - 无符号字符数组的输出