It looks like you're just starting out with C. Hopefully you have some experience with other languages, as C has a steep learning curve. Anyway, it's important to note a few things about C. The first is what void printSum(void);
really means. Breaking it down:
void printSum(void);
This declares a return signature. In other words, what the function gives back to you. In C, the word void
basically means "no variable". Remember that specifically. Why? Because C has another similar word, NULL
. NULL
means "no value." This is another way to look at it.
Some valid variables: int
, float
, bool
, void
Some valid values: 1
, 'c'
, 2.0f
, NULL
In reality, NULL
is actually just the number 0
. Literally. NULL == 0
will return true.
Moving on...
void printSum(void);
This defines the name of the item.
void printSum ( void );
The parentheses mean this is a function.
void printSum(void);
This represents a variable being passed into the system. So this could have been int, float, etc.
void printSum(void) ;
The semi-colon represents the end of a statement. This is a bit trickier of a concept to explain, but just think of it as finishing a sentence.
Now, the important bit here is the very first void
. If you tell C what kind of thing a function returns, it assumes you are talking about the function, not actually calling it. Omitting the first void makes C attempt to run the function instead of define or declare it.
The difference between defining a function and declaring it is interesting and might be best saved for when you're a bit more accustomed to C.