I am trying to make this simple code for practice in C. It asks the user to give a positive number, checks if it's positive or not, then returns just positive numbers.
I am getting this error:
positive.c:28:7: warning: implicit declaration of function 'GetInt' is invalid
in C99 [-Wimplicit-function-declaration]
n = GetInt();
I would have thought this meant I didn't declare one of my functions or that I didn't call in some library. To the best of my knowledge, I did all of this. Here is my code:
#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*/
}
Does anyone have any ideas on why this is giving me an error?