In my program, I have a function to output help/usage info, for the command-line usage, and it calls the function if the user types --help on the CL, but I want it to put in the name of the program as argv[0], but I can't get it to recognize argv in the function (it works fine in main(), but not for functions called in main).
When I compile using gcc I get this:
main.cpp: In function `int main(int, char**)':
main.cpp:37: error: expected primary-expression before "int"
main.cpp:37: error: expected primary-expression before "char"
If I get rid of (int argc, char** argv) from usage(), I get this:
main.cpp: In function `void usage()':
main.cpp:21: error: `argv' was not declared in this scope
main.cpp:21: warning: unused variable 'argv'
main.cpp: In function `int main(int, char**)':
main.cpp:37: error: expected primary-expression before "int"
main.cpp:37: error: expected primary-expression before "char"
It compiles with no probs if I remove argv[0] from the function...
Here is my code (just the important stuff, not the whole program...)
Wait... I may have tried to declare them while passing them, i.e usage(int agc, char** argv)... Come to think of it, I think I did do that, which, when I think about it, is stupid. Lol... I'll try that out real quick.
I guess I need to actually learn how functions work! The way I normally learn is I pretty much just dive into it head first, running on guesses and deductions until I run into problems, then I figure out how to fix them. Instead of actually learning how stuff works before diving into it.
On the plus side, I learn very quickly, on the down side, I run into a lotta probs!
Lol.