Need Some Help fixing my code

Hello! I'm currently working on a Match Card Game (it is a homework project)

This is just a segment of my code . I'm having problems with my Y/N statement. Whenever I run my program it Keeps on running If I type Y or N or anything else for the matter of fact.

I'm trying to get it to Accept the "Y" then display my "shuffle(cards) function. And If "N" to just continue with the regular loop.

Any advice is appreciated.

Thank You!

Fixed it thank you guys for the help it was just my braces that was out of place =o
Last edited on
Is this the entire code ... ???
I think you are using a wrong loop here... Use do while instead of while... Beacuse the loop works atleast once if given condition become false...
you should probably post the rest of the code if you can. It looks like you might be having some issues with the layout of your loop and the brackets but its hard to tell based on the chunk you posted
Okay I posted the full program sorry it was pretty huge so I thought posting the specific part would do.
Ok it clearly is a problem with your loops and brackets not lining up. You can tell because
}while(gameover != true); (on line 187) lines up with your opening brace of main. Thats a big no no and i was thoroughly shocked that g++ didn't complain when i compiled it. Also your variable i is unused.

Also you have a ton of formatting errors in here. ie weird spacing and stuff doesnt line up properly. although it isn't necessary for the program to run it will make it a hundred time easier to find issues like this if you keep everything looking nice and neat.

lastly on lines 119 and 120 you have opening braces for absolutely no reason. Although they don't cause the compiler to complain it is an awful idea to use opening braces for absolutely no reason. Id also suggest that you consider break this up into more functions. Its generally easier to maintain and find parts if you have it broken up in nice clean functions.

Topic archived. No new replies allowed.