Ask your own question, for FREE!
Computer Science 61 Online
sleepyjess:

blah blah blah

sleepyjess:

don't have everything in so far, but I'll explain the problem after I post what I have

sleepyjess:

it calls the `menu(menuSelection);` function properly, but not either of the others I have in

nuts:

can you link to pastebin?

sleepyjess:

what's that?

sleepyjess:

want me to put everything I have so far?

nuts:

wait what exactly is the problem?

sleepyjess:

just not sure why it isn't calling those functions corrently

sleepyjess:

*correctly

sleepyjess:

would a switch be better for this?

nuts:

you have a local/global variable problem. try moving the menuSelection variable before your main to make it a global variable so the functions can all operate on it @sleepyjess

nuts:

move menuSelection above int main()

nuts:

line 12 to line 9

sleepyjess:

and would line 13 need to be moved up also?

sleepyjess:

still doesn't work either way... just keeps running that first loop

nuts:

can you update your code with what you have real quick and i'll try to run it

sleepyjess:

updated

nuts:

in your "menu" function remove the argument int menuSelection and remove it in the call inside main (lines 47, 16, and 4) and try running without arguments. You're shadowing the global (you'd need the global keyword to write to it, but you don't need that argument in the function anyways)

nuts:

@sleepyjess

sleepyjess:

Yay!!! That worked!!

sleepyjess:

thank you so so so much, I really did not think it would take this long to find the issue

nuts:

yeah global and local variables are always a huge frustration the first time you encounter them since the behavior is completely unexpected

sleepyjess:

first time really having to work with declaring functions in general, so still a bit iffy on what I'm doing there

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!