I'm checking out the source code for cs50.c and found out that all the functions, e.g. GetChar or GetInt, require GetString(), but GetString() is defined at the end of cs50.c.

When programming in C, we should declare a function first if other functions will use it:

string GetString(void);

and then we could proceed to code the function at the end of the c file. This is not the case for cs50.c, so I wonder why does it not require the GetString function to be declared at the beginning of cs50.c? Does it have to do with that

#include "cs50.h"

is included in the file, and cs50.h declares the GetString function in the pre-processing before cs50.c is compiled?

Thank you very much for the help!

1 Answer 1


Yes you are correct. Since you answered your question yourself I don't see the point of giving an answer, but I'll do it anyway so that you can mark it as answered.

If you open cs50.h you will see the prototypes you describe. Those in turn get "pasted" in cs50.c when it includes it.

  • Thanks for confirming it, Chris.
    – Nahua Kang
    Aug 5, 2016 at 22:10

You must log in to answer this question.

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