What can cause a parse error?

This is a discussion on What can cause a parse error? within the Game Programming forums, part of the General Programming Boards category; I keep getting a parse error for line 146. It says before '}' which is the end of a do ...

  1. #1
    Deleted Account
    Join Date
    Mar 2003
    Posts
    62

    What can cause a parse error?

    I keep getting a parse error for line 146. It says before '}' which is the end of a do loop... please help i've tried everything.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You probably forgot a semicolon. Post your code so we can help more.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Deleted Account
    Join Date
    Mar 2003
    Posts
    62
    It's line 146.. parss error before '}'

    I would post the code but I couldn't find the code tag.
    Attached Files Attached Files

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You aren't using a do loop properly. The proper way to use it is:
    Code:
    do
    {
        Code to loop through...
    } while ( Condition );
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Deleted Account
    Join Date
    Mar 2003
    Posts
    62
    Thanks allot, I don't know why I missed it. I eaven mensioned the } was the end of a do-loop. It just went right over my head ,oh well.

    Here's the new source.. I still have lots of things to work out( choice 4, I'm using too many variabls) Mainly because this came from a previous allmost idintical game. But I realized to get more then two players would be hard the way I was doing it. So I came up with thit from the existing code.
    Attached Files Attached Files
    Last edited by zornthrohacker; 06-16-2003 at 06:15 AM.

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I would post the code but I couldn't find the code tag.
    its the number ( # ) symbol next to php and img

    I've often thought it would help to change that to "CODE" instead...

    Edit: Looking briefly through your code, I see at least one thing that could be done better. I don't see why you need to make x=q, when you could just use q.

    Code:
    int q=0;
    //int x; <--declare it in a loop
    
    cin>>q;
    //x=q; <--die!
    
    do
    {
    float pq[x];
    /*
    etc...
    
    
    */
      for (int x=0;x<q;x++)
          {
             pa[x] = 0;
            /*
            etc.
    
    
          */
         }
    Last edited by JaWiB; 06-15-2003 at 08:10 PM.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    Deleted Account
    Join Date
    Mar 2003
    Posts
    62
    Thanks, as I said before this code came frome some of my preveous code and I havn't weeded everything out.

    I updatd the code 2 posts above.

    I've found a new problem thoe. The iner most do-loop should... continue while 2 or more players have more then 2 states.

    Code:
    do
          {
             system("CLS");
    
             for (x=0;x<q;x++)
             {
                r1= 1+rand() %5;
    ...
    } while(1)//somehow while >1players has>0 states
    Last edited by zornthrohacker; 06-16-2003 at 06:44 AM.

  8. #8
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    im thinking something along the lines of having a state class. it could have a variable named "ownedBy" or something, and then have like:

    Code:
    enum OWNER { PLAYER1, PLAYER2, PLAYER3 };
     class state
    {
    ...
    private:
    OWNER whatever;
    };
    anyways i have to eat now, maybe ill add more later

  9. #9
    Deleted Account
    Join Date
    Mar 2003
    Posts
    62
    I can't do any modifications to the source because my computer I programm with got water in it.. I live on a hill but water came in the walls. I'm posting with my dad's computer right now, and he dosn't want anything installed or downloaded.

    Anyhow it just needs to dry out another 3-5 days and if it dosn't work my hardrive should be fine. If not I'll just download the source I posted . Anyhow I'm going to be gone for till next saturday.
    Last edited by zornthrohacker; 06-21-2003 at 06:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21