Weird error of expected unqualified id before

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samdude5556
    New Member
    • Nov 2017
    • 1

    Weird error of expected unqualified id before

    Hey guys i keep getting an "expected unqualified id before "{" token in line 19 anyone help please very urgent

    #include <iostream>
    using namespace std;


    int main();

    struct student
    {
    char name;
    int StudentID;
    float Aid;
    int Tuition;
    float Fee;
    float books;
    float housing;
    float meal;
    };


    {

    cout << "Enter information," << endl;

    cout << "Enter name: ";// Their name

    cin >> s.name;

    cout << "Enter StudentID: ";//StudentID input

    cin >> s.StudentID;

    if (s.StudentID =< 0) // incase they enter a 0
    {
    cout << "Please enter a real student ID";//Display their real student ID
    cin >> s.StudentID;
    }

    cout << "Enter Total Fincaial Aid: ";//Finacial Aid
    cin >> s.Aid;

    cout << "Enter amount paid for tuition: ";//Total tution before inputin seperate things
    cin >> s.Tuition;

    if (s.Tuition < 0)
    {
    cout << "You have to enter a real amount for your Tuition";
    cin >> s.Tution;
    }

    cout << "Enter the amount you paid purely for fees: ";
    cin >> s.Fee;

    cout << "Enter the amount you paid for books: ";
    cin >> s.books;

    cout >> "Entere the amount you paid for housing: ";
    cin >>s.housing;

    cout << "Enter the amount you paid for your meal plan: ";
    cin >>s.meal;




    cout << "\nDisplayi ng Information," << endl;
    cout << "Name: " << s.name << endl;
    cout << "Student Id: " << s.StudentID << endl;
    cout << "Total Aid: " << s.Aid << endl;
    cout << "Total Tution: " << s.Tuition << endl;
    cout << "Total Fees: " << s.Fee << endl;
    cout << "Total for books:" << s.books << endl;
    cout << "Total for housing:" << s.housing << endl;
    cout << "Total for meal plan:" << s.meal << endl;


    return 0;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You have a semicolon after main():

    Code:
    int main();
    The compiler thinks this is a function prototype. The code now appears to be outside any function so the error occurs when the { of the code is encountered.

    Comment

    Working...