私は 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*/
}
なぜこれが私にエラーを与えているのか、誰にもアイデアがありますか?