#need help with arrays

11 messages ยท Page 1 of 1 (latest)

sweet lotusBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

stone garden
jagged stirrup
#

you're using gotos to implement loops.You should just use loops lol

stone garden
#

my school has only introduced up to arrays atm,, i'm a 1st yr game dev student and we're a bit limited on what commands to use as well qwq

stone garden
#

the whole program is a guessing game basically,, the guessing game is done but the part where the name + guesses gets printed out is where I struggle

#

what does a vector do ?

jade crown
# stone garden the gotos r for when a new player comes and also for when their guess is incorre...

I would recommend against ever using the goto keyword, especially if you're new to programming since it will make you think of code as non-linearly executed. It's also rather annoying to read code that uses it. sadge As @obtuse jetty said you're declaring (fancy word for creating) a 1-dimensional array and then trying to access an element/index (fancy word for location/spot) as if it was a 2-dimensional array. For 1-dimensional arrays you should only have one [x]. If you're new to programming you should also avoid using vectors since you SHOULD know how arrays work before going into that ๐Ÿ‘Œ๐Ÿป .

#

I'm gonna eat now, but can look at how I would solve the issue after.

jade crown
#

I tried running your code after removing the [i] when you access the guesses array. It works then as we said. But you have a bug where you dont print the last guess when winning the game ๐Ÿ™‚

#

also, would recommend to remove the goto's and trying to control the flow using while, continue, and break.