首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >函数'GetInt‘的隐式声明在C99中无效

函数'GetInt‘的隐式声明在C99中无效
EN

Stack Overflow用户
提问于 2013-10-10 14:15:38
回答 4查看 9.6K关注 0票数 -2

我正在尝试用C语言编写这个简单的代码,它要求用户给出一个正数,检查它是否是正数,然后只返回正数。

我得到了这个错误:

positive.c:28:7: warning: implicit declaration of function 'GetInt' is invalid
  in C99 [-Wimplicit-function-declaration]
            n = GetInt();

我会认为这意味着我没有声明我的一个函数,或者我没有调用某个库。据我所知,这一切都是我做的。下面是我的代码:

#include <stdio.h>

int GetPositiveInt(void);

int main(void)
{
    int n = GetPositiveInt();
    printf("Thanks for the %i\n", n);
}


/*This all gets called into the above bit*/
int GetPositiveInt(void)
{
    int n; /*declare the variable*/
    do
    {
        printf("Give me a positive integer: ");
        n = GetInt();
    }
    while (n <= 0);
    return n; /*return variable to above*/
}

有人知道为什么这会给我一个错误吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19288370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档