I'm just wondering how exactly function arguments work. I know that the syntax for declaring a function is
and to use it is
returntype functionname ( variabletype variablename, etc);
but I would like to know, when you declare a function void playgame (int numberofenemies, int enemylevel); and then use it playgame (2, 3); does that make numberofenemies = 2and enemylevel = 3? And slightly more importantly, can I use that in a similar way to have the user choose x = bla1 and y = bla2 and then use the function playgame (y, x) and then have that make numberofenemies = y and enemylevel = x? :confused:
functionname (argumenttype argument, etc);
If I understand the question, yes, although to use a function (ie. call a function) you don't specify its argument type in the call.
If might be good if you could give us a code example demonstrating what you want to do.
And if I understand your second question correctly, then yes: you can use variables in a function call. The function will see the value of those variables (but won't be able to change the variables themselves).
Someone asked something just like this a day or two ago.
Variable names are meaningless. These two functions are EXACTLY the same:
int Subtract( int a, int b )
return (a - b);
int Subtract( int x, int y )
return (x - y);
Perhaps more accurately, parameter names are not significant to the function signature, though of course you should still use meaningful names.