Thread: A really, really stupid question, what is parse? and how do I get rid of it?

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    4

    Question A really, really stupid question, what is parse? and how do I get rid of it?

    I've violated my cardinal rule by posting this, never make your first post a question, but since i have close to no expierince with any C langauge this is the way it's gonna have to be.

    Ok, here is my question, I've written a couple of really simple math programs (really really really simple) and there pretty useless beacause whenever the program get's to the end and hits the "system ("pause");" line I hit a key and the program quits, not very usefull for doing several of the same problem type over and over again. So I try to add any kind of loop do while loops just plain while loops, and even if (1==1) loops, but whenever I try to compile this code (using Dev C++ Ver. 4.9.8.0) the compiler gets the first line that has to do with a loop and says "parse" down in the compiler "box of errors" (as i like to call it) like It's an error. what does this mean? is it like a syntax error? here is what my code looks like:
    Code:
     do{
     Everything in here works whithout the do or while statement
    } while (1==1)
    I know this is a stupid question but it's beenbugging me for a couple of days now, I read the help file, the FAQ, this sites FAQ, more than one other sites FAQ, searched through post's and couldn't find any help. Thank you.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    You have to put a ";" at the end of the do....while(condtion) loop.
    http://www.cprogramming.com/tutorial/lesson3.html
    Woop?

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    Thank you this is true, but the compiler didn't even get to the "while" line in my code it simply stopped at do, could this simply be my compiler? I've checked it severel times and i thinkmy syntax is correct, should i post the code for the entire program?

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Well sure. Ussually with a parse error it is roundabout the line that has the error.
    Woop?

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    I really hat dragging this out, but... I did fix the last line and it still dosn't work, this is really annoying me now so I'm going to post more of my (simple) code, dang it though; I wanted to figure it out myself, here's some more code:
    Code:
    #include <iostream>
    #include <fstream>
    #include <stdio.h>
    #include <math.h>
    using namespace std;
    int main(int argc, char **argv);
    do { 
    int a;
    int c;
    int b;
    double q;
    int p;
    double f;
      cout << "Please enter known leg: ";
      cin >> a;
      cout << "Please enter hypotanuse: ";
      cin >> c;
        q=(c*c)-(a*a);
        p=(c*c);
        f= sqrt(q);    
      cout << "The values you entered are " << a <<" " << c << ".\n ";
      cout << " and it equals " << q << "= b^2 \n \n";
      cout << "The missing leg is: " << f << " \n \n";
      system ("pause"); 
    } while (1==1);
    return 0;
    }
    return 0;
    }
    what seems to be the problem? if there's a way you could point me in the right direction without giving it away that would be great!

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Well you might want to work on spacing it makes your life so much easier.
    Code:
    #include <iostream>
    #include <fstream>
    //C++ headers don't have a .h
    #include <cstdio>
    #include <cmath>
    using namespace std;
    
    //Removed ; from the end of main
    int main(int argc, char **argv)
    {
        //I would put these outside of the loop block
        int a;
        int c;
        int b;
        double q;
        int p;
        double f;
        
        do
        {
            cout << "Please enter known leg: ";
            cin >> a;
            cout << "Please enter hypotanuse: ";
            cin >> c;
            
            q =(c*c) - (a*a);
            p =(c*c);
            f = sqrt(q);    
            
            cout << "The values you entered are " << a <<" " << c << ".\n ";
            cout << " and it equals " << q << "= b^2 \n \n";
            cout << "The missing leg is: " << f << " \n \n";
            
            //Consider a better option than system("pause")
            system ("pause"); 
        } while (1);
        //You had extra braces and return statement
        return 0;
    }
    Read this as well. http://faq.cprogramming.com/cgi-bin/...&id=1043284385
    Woop?

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    Many thanks, on a side note the people on this board that know a lot seem to be very willing to help and courteous everyone here should take that as a complement.
    Last edited by element; 11-04-2005 at 12:03 AM.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> //I would put these outside of the loop block

    I would leave it in, and move them to where they will be initialized, like this:
    Code:
    int main(int argc, char **argv)
    {
        do
        {
            int a;
            cout << "Please enter known leg: ";
            cin >> a;
    
            int c;
            cout << "Please enter hypotanuse: ";
            cin >> c;
    
            double q =(c*c) - (a*a);
            int p =(c*c);
            double f = sqrt(q);    
            
            cout << "The values you entered are " << a <<" " << c << ".\n ";
            cout << " and it equals " << q << "= b^2 \n \n";
            cout << "The missing leg is: " << f << " \n \n";
            
            //Consider a better option than system("pause")
            system ("pause"); 
        } while (1);
        //You had extra braces and return statement
        return 0;
    }

Popular pages Recent additions subscribe to a feed