Thread: Prog ran fine Friday, now won't work, don't know why

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    10

    Unhappy Prog ran fine Friday, now won't work, don't know why

    I left this prog working just fine on Friday. Now I want to run it, and I get all kinds of weird errors. I really have no clue why, any suggestions? It's really a very simple program, all it has to do is create 2 structs, then create 2 instances and print them out, first one by one, and then using the ostream & operator.

    #include <fstream>
    #include <iomanip>
    #include <iostream>
    #include <string>
    using namespace std;
    struct PERSON
    {
    char FirstName[20];
    char LastName [20];
    char Telephone[20];
    char StreetAddress[50];
    char Town[20];
    char State[20];
    int Zip;
    };
    struct LASTQUESTION
    {
    char Name[20];
    int age;
    char State[20];
    }

    ostream &operator << (ostream &os, const PERSON &x)
    {
    os << "This is using method from question 4" << endl
    << "First name: " << x.FirstName << endl
    << "Last Name: " << x.LastName << endl
    << "Telephone: " << x.Telephone << endl
    << "Street Address: " << x.StreetAddress << endl
    << "Town: " << x.Town << endl
    << "State: " << x.State << endl
    << "Zip: " << x.Zip << endl;
    return os;
    }

    int main ()
    {
    PERSON prof;
    strcpy(prof.FirstName,"Mr.");
    strcpy(prof.LastName,"Harris");
    strcpy(prof.Telephone, "1800555787");
    strcpy(prof.StreetAddress, "1600 Pennsylvania Avenue");
    strcpy(prof.Town, "Washington");
    strcpy(prof.State, "DC");
    prof.Zip = 20001;

    PERSON stud;
    strcpy(stud.FirstName,"Joe");
    strcpy(stud.LastName,"Schmoe");
    strcpy(stud.Telephone, "3018675309");
    strcpy(stud.StreetAddress, "99 Red Balloons Ave");
    strcpy(stud.Town, "Arlington");
    strcpy(stud.State, "VA");
    stud.Zip = 20812;


    cout << "Professor Info (using method question 3)" << endl; //print out professor info question 3
    cout << "First name: " << prof.FirstName << endl;
    cout << "Last name: " << prof.LastName << endl;
    cout << "Telephone: " << prof.Telephone << endl;
    cout << "Street Address: " << prof.StreetAddress << endl;
    cout << "Town: " << prof.Town << endl;
    cout << "State: " << prof.State << endl;
    cout << "Zip: " << prof.Zip << endl <<endl;


    cout << "Student Info (using method question 3)" << endl; // print out student info question 3
    cout << "First name: " << stud.FirstName << endl;
    cout << "Last name: " << stud.LastName << endl;
    cout << "Telephone: " << stud.Telephone << endl;
    cout << "Street Address: " << stud.StreetAddress << endl;
    cout << "Town: " << stud.Town << endl;
    cout << "State: " << stud.State << endl;
    cout << "Zip: " << stud.Zip << endl << endl;
    cout << prof;
    cout << stud;

    return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    Code:
    struct LASTQUESTION
    {
    char Name[20];
    int age;
    char State[20];
    }; //<-- Missing ;

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    You're missing a semicolon after the second struct:
    Code:
    struct LASTQUESTION
    {
    char Name[20];
    int age;
    char State[20];
    }; // <---

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    10
    Wow!! that did it!!! Thank you both , I appreciate it! I have no idea where it went, it was there Friday! Thnaks again!

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Please use code tags (see my sig for an example).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 10-16-2006, 12:04 PM
  2. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  4. Prog won't work after i press enter...
    By emperor in forum C Programming
    Replies: 8
    Last Post: 07-04-2002, 08:47 AM
  5. what do you you mean, this prog doesnt work??
    By ... in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:17 PM