Originally Posted by
digdug4life
this is a kind of nubish post, cause im still a noob, but dont you need braces or whatever they're called for those if statements?
The only reason that is a noobish question is because I just answered it. I even gave multiple examples.
Here it is... one more time.
You don't need braces if the statement you wish to perform after the if statement is one line long. If it's more than one line, it needs braces.
Code:
if ( 1 == 1 )
cout << "This is a proper if statement" << endl;
cout << "...but this line isn't part of the if statement";
if ( 1 == 1 ) {
cout << "This is a proper if statement" << endl;
cout << "Now this is part of the if statement";
}
if ( 1 == 1 )
cout << "This "
<< "is "
<< "also "
<< "all "
<< "part "
<< "of "
<< "the "
<< "if "
<< "statement."
<< endl; // The semicolon ends the statement.