cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : Being able to "Keep Track of.."
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

post  Being able to "Keep Track of.."

Spinage209 (4)
So i am making this "Number Guessing" game for a school lab.

And i need to be able to keep track of how many turns the player has taken.

So any kind of example code would be appreciated. I am not sure if i can post my code on here, but if there is a way me to PM you, then i would gladly do that.
|
bluegray (29)
create a variable int count = 0;
in your loop after each time the player makes a guess put in count ++

hope i understood your question right!
|
Spinage209 (4)
Well it seems to work but not exactly. It just seems to stick with
"Pick again1" Here is a peice of the code where the loop is, that is where i put it. Dont know if it will work there, or if i did it right.

while ( answer != guess)
{
int count = 0;

cin >> guess;

count++;



if(answer != guess)

{
cout << "Pick again" << count <<endl;
}

else
{
cout << "true" << endl;
}

}




NO wait, i figured it out. Thanks a bunch, appreciate the help. thnks!
| Last edited on

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us