Thread: compiling problem

  1. #1
    Registered User
    Join Date
    Jun 2005

    Smile compiling problem

    This error appeared when I tried compiling theprogram:

    fatal error C1075: end of file found before the left brace '{' at 'c:\Documents and Settings\TinkerBell\My Documents\Visual Studio Projects\new280\new280.cpp(4)' was matched
    Here is my code: (I know it's long.. but the program itself does not matter... I think it's the include...)
    Thanks, The utterly confused

    #include <iostream>
    using namespace std;
    int hour, time_day;
    char veh[6];
    cout << "Do you drive a car or a truck?" << "\n";
    cin >> veh;
    cout <<"You drive a " << veh <<"\n";
    cout << "Please choose how many hours you parked:" << "\n";
    cout << "1. 1 hour" << "\n";
    cout << "2. 2 hours" << "\n";
    cout << "3. more than two hours" << "\n";
    	cin >> hour;
    cout << "You have to pay: " << "\n";
    {	case(3): {cout << "$5" << "+" << "\n";}
    	case(2): {cout << "$3" << "+" << "\n";}
    	case(1): {cout << "$2" << "\n";}
    if( !strcmp(veh, "truck") ) /* strcmp returns 0 if veh equals to "truck" */
        cout << "+$1" <<  "\n";
    cout << "When did you park ? ";
    cout << "1. Before 8 A.M" << "\n";
    cout << "2. Before 5 P.M" << "\n";
    cout << "3. After 5 p.m" << "\n";
    	cin >> time_day;
    	{case(1): {cout << "That's all thank you";
    	case(2): {cout << "You have to pay 50 cents more";
    	case(3) : {cout << "You get back 50 cents";
    return 0;}

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Look carefully at your last switch-case structure... in particular case(3)
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2005
    Oh thank you! forgot to put }

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    If you line your braces up vertically instead of the style you have used you would never have needed to post this, you would have spotted the missing brace in a second.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  5. #5
    Join Date
    May 2005
    Check if your editor supports automatic highlighting of missing braces.

  6. #6
    Registered User
    Join Date
    Jun 2005
    How do I find that? I have Microsoft Visual Studio.Net

  7. #7
    Registered User mitakeet's Avatar
    Join Date
    Jun 2005
    Maryland, USA
    Put your cursor next to the brace you want the match for and type control ']' and it will jump to the matching brace. The same thing works for parenthases as well, btw.

    Free code:

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Running Program After Compiling
    By kristentx in forum C++ Programming
    Replies: 13
    Last Post: 09-12-2007, 10:46 AM
  2. Compiling 3rd party code problem me too
    By siavoshkc in forum C Programming
    Replies: 1
    Last Post: 09-12-2007, 05:55 AM
  3. Problem compiling simple code examples
    By Wintersun in forum Windows Programming
    Replies: 8
    Last Post: 08-14-2007, 10:30 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. simple compiling problem
    By waxydock in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 10:33 AM