I need to write a C++ program. I'm usually pretty decent with C++ but with this one I'm lost. I have to write a program that basically checks to make sure that the braces creating a block in a cpp file are balanced. I'm not looking for anyone to write it for me but I was hoping someone could help me out or point me in the right direction. I've attached the requirements to the post. I don't know how to check for balanced braces and where I REALLY get lost is how to reposition the braces as stated and how to ignore ones not creating a block.
Jump to Post
Create a counter of how many "levels" of braces you are in. What do you mean by reposition? To see if they are part of a block, look at the statement before the opening brace. If it is a for loop, if statement, etc. then it is valid.
All 6 Replies
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.