I'm getting an error in this line:

int x = get_int();

clang says:

water.c:7:13: error: implicit declaration of function 'GetInt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    int x = GetInt();

This line works fine in other programs, as copied from the lecture- what's up?

  • There is nothing visibly wrong with the code you have provided. Perhaps you can include your entire code? I used int x = get_int(); in a test program I made and there is no compilation error. I suggest refreshing, resaving, and re-compiling the file. If you are still getting errors, you might consider using GetInt() instead and see if that works. Commented Jan 30, 2017 at 14:15
  • I had the same problem. get_int() needs an argument in between the parentheses. I put (0) in and the program now runs as intended. I hope that helps. I bit into this one today. Commented Jun 19, 2019 at 16:13

2 Answers 2


implicit declaration of function 'GetInt' is invalid in C99 Though daunting, the compiler makes it very clear - your code implies that you want to use GetInt, but you instead use get_int(). I have found that, at times, the compiler and CS50 library can be very sensitive, so it is best to use the regular version, GetInt(). In the CS50 file, how GetInt is named/defined - get_int, Get_Int, GetInt, or any variation thereof - can affect how the function performs and how to call on that function.

I created a test program to show you how that works. Here is my test program:

// define function
bool function(int a, int b);

int main(void)
    // set variables
    int x = 0; 
    int y = 1;

    // check if function evaluates to true
    if (Function(y, x) == true)
// checks if a > b
 bool function(int a, int b)
    if (a > b)
        return true;
        return false;

Since GetInt is a function, I chose to create a function called function that tests if int a is less than int b. You'll see that in the line if (Function(y, x) == true), I test to see if the function returns true. However, I use a different spelling - Function instead of function. This returns the same error that you get on your program:

something.c:13:9: error: implicit declaration of function 'Function' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (Function(y, x) == true)

When I change Function to function, the original spelling I define my function as, I can compile just fine without any errors. I hope that my example can explain why get_int might be considered invalid - and show you why you might get that error in the future.

int x = get_int() worked for me in another program I created, but I have seen from other answers that CS50 is case-sensitive. However, get_int should work, and if it doesn't, you might want to consider re-saving, re-compiling, and refreshing your file. However, if you want to go the "easy" route, you can change get_int() to GetInt().

If this answers your question, please click the green checkmark! Comment below if you still have issues/questions.

  • Wow- more than I expected- thanks! I already solved the problem myself a few minutes after I posted (forgot the library).
    – Rick
    Commented Feb 2, 2017 at 3:01
  • @Rick No problem! Glad to hear you solved it. If you found the answer to your question, post it as an answer and accept it or accept one of the other answers - that way this doesn't stay in the unanswered section! Commented Feb 2, 2017 at 14:32

Did you #include <cs50.h>?

  • Yeah- already figured that out- thanks.
    – Rick
    Commented Jan 30, 2017 at 7:26
  • i have used #include <cs50.h> header, but still facing the same problem. The cs50 complier continuously showing the following error message:- > " implicit declaration of function 'GetInt' is invalid in C99 > [-Werror,-Wimplicit-function-declaration]"
    – ASIF
    Commented Jun 20, 2021 at 5:29
  • @ASIF Please start your own question, so that the answers can pertain to your specific issue and not cause your issue's info and resolution to be confused with this one's. Commented Jun 20, 2021 at 11:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .