5 Replies - 688 Views - Last Post: 25 November 2013 - 03:59 PM Rate Topic: -----

#1 renee29581  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-November 13

need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:02 PM

I have completed most of the assignment for my hangman project for c + +. The only thing I cant figure out is how to clear the screen from showing the word that the person has to guess and how to keep track of what letters the user has guessed already.
when I use //clear system
system("cls");
it wont work in dev c++ it says that system hasn't been declared and when I try to declare it, it says it cant be used as a function so im confused with that.
then for keeping track of the letters guessed this is what I have so far.
for(letter != 6)
	{
		cout << "Letter has already been guessed, choose another letter " << endl;
		cout << guess << letter << endl;
	}//end for



I don't know why this wont work. it says something about 6 cant be in there. I have no clue
thank you
alicia

This post has been edited by no2pencil: 25 November 2013 - 03:10 PM
Reason for edit:: added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: need helping trying to figure out how to keep track of users guesses

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,122
  • Joined: 12-June 08

Re: need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:14 PM

Perhaps collect all the tries in some sort of group.. like a collection.. say a list or array?

http://www.cplusplus...ence/list/list/
http://www.cplusplus...utorial/arrays/


Quote

it wont work in dev c++ it says that system hasn't been declared and when I try to declare it, it says it cant be used as a function so im confused with that.

Did you include the right library?
#include <cstdlib> 

Was This Post Helpful? 0
  • +
  • -

#3 renee29581  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-November 13

Re: need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:28 PM

View Postmodi123_1, on 25 November 2013 - 03:14 PM, said:

Perhaps collect all the tries in some sort of group.. like a collection.. say a list or array?

http://www.cplusplus...ence/list/list/
http://www.cplusplus...utorial/arrays/


Quote

it wont work in dev c++ it says that system hasn't been declared and when I try to declare it, it says it cant be used as a function so im confused with that.

Did you include the right library?
#include <cstdlib> 

I have never heard of that code before. then again this is my first class. I was thinking that's probably what I am going to have to do but trying to figure it out is giving me a headache. I am going through the book trying to see if it will talk about it but I cant find any information
Was This Post Helpful? 0
  • +
  • -

#4 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1852
  • View blog
  • Posts: 6,664
  • Joined: 19-February 09

Re: need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:40 PM

Hi, welcome to DIC.

You could use a string to keep track of letters that have been guessed.

If you don't want the user to see the answer, don't print it.
Was This Post Helpful? 0
  • +
  • -

#5 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 408
  • View blog
  • Posts: 882
  • Joined: 27-June 09

Re: need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:48 PM

for(letter != 6) 


Did you mean while(letter != 6) ? For loops need starting states, conditions, and reoccurring actions. Even if these are blank, they need to be present to be considered valid syntax.

for(/*blank initial state*/;letter != 6;/*blank action*/)

Was This Post Helpful? 0
  • +
  • -

#6 renee29581  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-November 13

Re: need helping trying to figure out how to keep track of users guesses

Posted 25 November 2013 - 03:59 PM

View Post#define, on 25 November 2013 - 03:40 PM, said:

Hi, welcome to DIC.

You could use a string to keep track of letters that have been guessed.

That is what I am working on now. Using a string and trying to figure out how to word it so its right.
If you don't want the user to see the answer, don't print it.

I got that part to work
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1