Re: Syntax errors will be the death of me!

  • From: "RicksPlace" <ofbgmail@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 11 Jul 2010 07:12:10 -0400

Sorry for the general post Jes: I forgot you were doing it using a command line 
compiler and the other guys have nailed it. I just got up this morning and saw 
your first post when I started going through my unread mail messages. Usually I 
go through them in reverse order but... well I got lazy this morning. . 
Rick USA
  ----- Original Message ----- 
  From: RicksPlace 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Sunday, July 11, 2010 6:56 AM
  Subject: Re: Syntax errors will be the death of me!


  I don't do C# or C++ but I see that there is a colon after the  switch 
statement literal, I think you defined it as an int.
  Also, reading one line at a time with Windoweyes in this post I get 2 
statements in the Switch statement on each line. I'm not sure if that is the 
case in your editor but you might check it out.
  Finally, check to make sure you need semicolons in each place inside the 
switch statement. 
  If you are building in Visual Studio or one of the Express modules it should 
give you the line and column of the error. You can double click the error 
message in the Error List and have your cursor placed on the line in question. 
You might try that and even copy the line in question to a post if you can't 
figure it out or someone else has not answered this question already.
  Rick USA
    ----- Original Message ----- 
    From: Jes 
    To: programmingblind@xxxxxxxxxxxxx 
    Sent: Saturday, July 10, 2010 10:20 PM
    Subject: Syntax errors will be the death of me!


    Hey guys, 
    Here's a code for an assignment which has to be turned in tomorrow. Every 
time I try to compile it, Visual Studio keeps telling me I'm missing a ; before 
<<
    What's wrong?
    Code follows:
    //Ch6ConE06.cpp
    //Displays a class rank based on a code 
    //entered by the user
    //Created/revised by <your name> on <current date>


    #include <iostream>


    using std::cout;
    using std::cin;
    using std::endl;


    int main()
    { 
      //declare variable
    int code = 0;


    //enter input
    cout << "Enter the code: ";
    cin >> code;
    //enter switch statements
    switch(code)
    {
    case 1:;
    cout << "Freshman. " ; << endl;
    break;
    case 2:
    cout <<"Sophomore"; << endl;
    break;
    case 3:
    cout << "Junior "; << endl;
    break;
    case 4:
    cout << "Senior" ; << endl;
    break;
    case 5:
    cout << "Error! "; << endl;
    }
    //endswitch
    //display output


        return 0;
    }   //end of main function


    Jes

Other related posts: