void EnterWord()
{
char solution[20];  //holds solution
char blank[20];     //holds "*"'s for unsolved letters
int Subscript=0;
int State=1;
char Guess[20];
char Copy [20];
char Letter;
int Correct =0 ;
// input the string and getline it
cout<<"Enter phrase 20 chars or less."<<endl;
cin.getline(solution, 20);
int Word; // this will hold the subscript of our word
int Size; // this will hold the length of our word     int State = 1 ; // This will hold the game state.     int Subscript= 0; // This will hold the subscirpt     char Guess [MAX_WORD_SIZE]; // this will hold their current word     char Copy [MAX_WORD_SIZE]// this will hold a copy of word
char letter;// this will be their letter guess     int Correct = 0  ; // This is a true/ false value
//Create a null terminated string to represent the word as the player know it//
for ( ; Subscript < Size; Subscript++)
{
Guess [Subscript] = '-';
}
// insert the null character
Guess [Subscript] = '\0';
// Go until the player is hung
while (State!=6)
{
DrawGallows(State);
cout << Guess << endl;
cout << "Guess a letter:" ;
cin >> letter;
// use only lower case letters
Letter = tolower(Letter);
for (Subscript = 0 ; Subscript < Size; Subscript ++ )
{
if (Copy[Subscript]== Letter)
{
Guess [Subscript] = Letter;
Correct =1 ;
cout<< endl<< "Good Guess";
// If guess equals the word they won so exit
if (strcmp (Words[Word],Guess) == 0 )
{
cout << endl << "Congratulation !! You won !!" << endl;
return;
}
}
}
// If they did not guess correctly
if (Correct == 0)
{
cout<< endl << "Sorry,bad guess!";
State++;
}
Correct = 0 ;
}
DrawGallows(State); // Draw the gallows at end of game
cout << "the word was : " << Words [Word]<< endl << endl;
}

can you help me correct this code, I am confused, because when I enter the input to run this function, it announce the window error? not the normal C++ error ?

Edited 3 Years Ago by happygeek: fixed formatting

for ( ; Subscript < Size; Subscript++)
	{
		Guess [Subscript] = '-';
	}

I'm guessing problems happen here? What value is Size?

Please give the actual message statement from the windows error message, that will help a lot. My crystal ball needs new batteries. (still)

Also, please post code using code tags, not quote tags, like

[code]

your code goes here

[/code]

"program 5 final. exe has encountered a problem and needs to close. We are sorry for the inconvenience" . That how it is, there are no other problem, can you correct for me please, it will be dued tommorow

"program 5 final. exe has encountered a problem and needs to close. We are sorry for the inconvenience" . That how it is, there are no other problem, can you correct for me please, it will be dued tommorow

Shall we correct it here, here, or here? Close two of the three threads please.

That's a runtime error, not a compile error, and not a very specific error. Run it from the command prompt and see if you get a more specific error please.

Without a full program to compile, we can't find the error. Your function has four different char arrays, only one of which you assign any content at all. Where does the Words array come from - you're not using a global variable, are you? That's a naughty no-no!;)

I find it hard to believe you're getting a runtime error, as I don't see that this code would compile yet.

This question has already been answered. Start a new discussion instead.