Error at line 76 but code ends at line 75... wtf?

I get this error while compiling with MS Visual C++ Express.

1>------ Build started: Project: Book Exercises, Configuration: Debug Win32 ------
1> Word_Jumble.cpp
1>c:\documents and settings\matt\desktop\programing\book_exercises\word_jumble\word_jumble.cpp(77): fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\matt\desktop\programing\book_exercises\word_jumble\word_jumble.cpp(12)' was matched
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Here's my code:

// Word Jumble
// A classic word game. Ask hints to guess the correct word

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

int main ( )
{
enum fields {WORD, HINT, NUM_FIELDS};
const int NUM_WORDS = 5;
const string WORDS [NUM_WORDS] [NUM_FIELDS] =
{
{"wall", "Are you banging your head against something?"},
{"glasses", "These might help you see the answer."},
{"labored", "Going painfully slow"},
{"persistent", "Keeping at it"},
{"jumble", "All mixed up."}
};

srand (static_cast < unsigned int > (time (0) ));
int choice = (rand ( ) % NUM_WORDS);
string theWord = WORDS [ choice ] [WORD]; // Jumbled verison
string theHint = WORDS [ choice ] [HINT]; // the hint

string jumble = theWord; //Jumbled word
int length = jumble.size( );
for ( int i = 0; i < length; ++i )
{
int index1 = ( rand( ) % length );
int index2 = (rand( ) % length );

char temp = jumble [index1];

jumble [index1] = jumble [index2];
jumble [index2] = temp;

// Welcoming the player

cout << "\t\tWelcome to word jumble!\n\n";
cout << "Unscramble the letters to make a word. \n";
cout << "Enter 'hint' for a hint.\n";
cout << "Enter 'quit' to quit the game.\n\n";
cout << "The jumble is: " << jumble;

string guess;
cout << "\n\nYour guess: ";
cin >> guess;

while ( ( guess != theWord ) && ( guess != "quit" ) )
{
if ( guess == "hint" )
{
cout << theHint;
}
else
{
cout << "Sorry, that's not it.";
}

cout << "\n\nYour guess: ";
cin >> guess;
}

if ( guess == theWord )
{
cout << "\nThat's it! You guessed it!\n";
}

cout << "\nThanks for playing.\n";

return 0;
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I've been teaching myself C++ with a book called "Learning C++ through game programming" and this is an exercise in the book. As far as I can tell, This code is the same as the example in the book. Still, I get this error. I'm sure its some obvious thing that i'm just missing, but I've run into a wall here.

Any help would be appreciated.

O
Rethink line 55 through 62.

EDIT: Oh yeah, and you're missing a close brace for your "int main()"
Last edited on
Topic archived. No new replies allowed.