multiple lines per command

I am working on a small program that runs on commands. I need to be able to run multiple lines of code for that command, I have this code:

1
2
 if(command == "exit") 
            break;


So, how could i run 2 lines with this?
Why aren't you using curly braces? You should always use curly braces.
What LB means, is that you should learn to format your code.
You did that with break by indenting it.
Part of formatting is to make it readable.
Taking shortcuts, is considered bad programming.
As you can see below adding curly braces makes it easy to see where the if begins and ends.

1
2
3
4
5
6
if(command == "exit") 
{// Begin if
   Command 1
   Command 2
   Command ...
}// End if 


Imagine trying to understand the below pseudo code without good formatting.

1
2
3
4
5
6
7
While (true)
if (nottrue)
goto dosomething;
print helloWorld;
if (notdone)
do somethingelse;
print done;

Last edited on
Topic archived. No new replies allowed.