Original Post
Let me preface by staying that I swear I'm not a noob to programming in general-- just apparently to C. I've done lots of C++. I'm hitting a sort of quirk, and I'm not sure why. Assume that createStack is defined after main and has prototype: int createStack(Element **stack); I have the following code:
int main (int argc, char * const argv[]) {
Element *stack;
createStack(&stack);
int push1 = 3;
return 0;
}
That does not compile (Visual Studio 2005, project set to strict C compiling). However, if I change that code to:
int main (int argc, char * const argv[]) {
Element *stack;
int res = createStack(&stack);
int push1 = 3;
return 0;
}
changing only a variable declaration that stores the result of the function call, it compiles just fine. I thought that one (for better or for worse) need not use the return value of a function, even if said function provides one. Is that a C++ "extension," or is there some other foul essence at play here? Thanks in advance for any replies. Google searching turns up a lot about how to declare functions with return types, but not whether the caller need acknowledge that there is a return value.