While going through some allegro tutorials I found an odd call.
int al_init();
The function al_init() initializes allegro so that the allegro functions can be used. What is with the int al_init(); line? If I change this line of the code to exclude int it works the same, but if I take out the line altogether it does not work. What is this line doing? The only thing I can imagine is that it creates an integer and assigns it the return value of the al_init() function, with that likely being -1 for failure and 0 for success etc. But if that is what this is doing, then how can you even check the return value?
In C/C++ there are function declarations and function definitions:
Declarations look like these:
Explanation:
int,void,double) describes the type of value returned by the function.int(which is why it works when you removeintfromint al_init(), but not when you remove the declaration altogether)voidmeans it’s not supposed to return a value (even though technically it can, but that’s for rarer cases)Definitions look like these:
Notice the difference:
;{and}, but no;!a_function, it expects no arguments, and it returns a value of typeint.