函数'getchar'的隐式声明在C99中无效。我对这个警告感到困惑

时间:2018-08-31 16:00:30

标签: c warnings

我是C语言编程的新手,我试图编写一个接受两个int输入并将ascii转换为int值的函数。我不明白我收到的错误。

warning: implicit declaration of function 'getchar' is invalid in C99 [-Wimplicit-function-declaration]
    char current = getchar();
                   ^
int ascii2int (int radix, int valueOfPrefix) {
    //set a char (variable) to getchar() 
    char current = getchar();

    //Check to see if the current char is at the end of the line
    if (current == '\n'){
        return valueOfPrefix;
    }
           //recursivly recall the function 
    return ascii2int(radix, valueOfPrefix*12 + char2int(radix,current));
}

0 个答案:

没有答案