Thread: Compiler error in whitespace that doesn't even exist

  1. #1
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69

    Question Compiler error in whitespace that doesn't even exist

    Hi, I was writing a pick a random number program, and on line 31 (line number is shown in comment), it says for the errors: ` and [Each and `. Also on line 50 (doesn't even exist) it says that there is parse, but is whitespace that doesn't exist parse? If anybody has any idea what these errors mean and/or how I can fix them, that would be awsome.
    Code:
    #inclued <cstdlib>
    #include <ctime>
    #include <iostream>
    int game()
    {
        using std::cout;
        using std::cin;
        using std::endl;
    
        srand((unsigned)time(NULL));
        int randomnum, number;
        randomnum = rand();
    
        cout << "Guess a number: ";
        cin >> number;
    
        if (randomnum == number)
        {
            cout << "You Win!!!!!!!";
        }
        if (randomnum != number)
        {
            cout << "You Lose!!!!!!" << endl;
            cout << "The number was " << randomnum << ".";
        }
        if (randomnum == number || randomnum != number)
        {
            cout << endl << "Play Again? Y/N" << endl;
            char again;
            cin >> again;
            if (again == Y || again == y) //THIS IS LINE 31	
            {
            int game;
            }
            else
            {
            return 0;
            }}
        else
        {
            cout << "Error Occured";
            Sleep(2000);
            return 0;
        }
    int main();
    {
        int game();
        return 0;
    }
    Thanks for any help,
    Adam

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Maybe it's trying to suggest what you should be doing.
    Code:
    if (again == 'Y' || again == 'y') //THIS IS LINE 31
    And this ain't right.
    Code:
    #inclued <cstdlib>
    And you're missing the closing brace for the function game.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69
    Thank you, it is fixed!!
    Adam

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  4. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM