Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

StoNeD_TrOLL

Problem with if

This topic is 6008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay,I am having a problem ending this if statement.My complier puts whatever is after my if statement in the statement.Heres the code: if (ank == 7) std::cout<<"_X_|___|___\n"; std::cout<<"___|___|___\n"; std::cout<<"___|___|___\n"; std::cout<<" | |\n"; so how do i end it?

Share this post


Link to post
Share on other sites
Advertisement
Enclose everything inside the if statement in braces {}. So ...
if (ank == 7)
{
std::cout << "blah\n";
...
...
}
std::cout << "We are no longer in the if statement\n";

Share this post


Link to post
Share on other sites
I though flush only cleared the input buffer? Or is it just one general buffer. I always use endl tho...

Share this post


Link to post
Share on other sites
Remember that cout, cin, fstream, ofstream, ... are all subclasses of iostream/iobase (or something like that anyway). so most funcs can be used accross the board and will achive similar results.

this is foolproof and if it doesn't work check your compiler settings (i'll be assuming that you're in std namespace 'using namespace std;' for simplicity):

if (ank == 7) {
cout << "_X_|___|___\n";
cout << "___|___|___\n";
cout << "___|___|___\n";
cout << " | |\n";
}
or you could take a small shortcut:

if (ank == 7) {
cout << "_X_|___|___\n"
<< "___|___|___\n"
<< "___|___|___\n"
<< " | |"
<< endl;
}

Edited by - Krysole on February 2, 2002 11:27:20 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!