Thread: create an array

  1. #1

    create an array

    Hi! I am new at this and my homework this week is to create an address book , using a defined structure and an array (so many enteries can be stored.) So, I have started this, but am stuck, do you have any idea's. Like I said, I am very new at all this and would just like suggestions not answers! Thanks

    #include <iostream.h>

    struct AddressBook
    char Name[15];
    char Address[15];
    char City[25];
    int age;
    int zip;
    int phonenumber;


    void main()


    cout<<"Enter the information into the address book!";

    cout<< Enter the Name: ";
    cin.getline (Name, 20);

    cout<<"Enter the address: ";
    cin.getline (Address, 20);

    cout<<"Enter the City and abbreviated state: ";
    cin.getline (City,30);

    cout<<"Enter the Zip code: ";
    cin.getline (Zip, 6);

    cout<<"Enter the phone number including area code (please do not add a hypen or space): ";
    cin.getline (Phonenumber, 10);

    cout<<"Enter the age of this person: ";
    cin.getline (Age,3);


  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    first, let me say this otherwise others (especially prelude) will go ballistic:
    don't use void main(). ever. ever. never ever ever use void main.
    use int main() instead.

    you're off to a good start. create an array of structs. create a loop to keep receiving answers until the user of the program wants to quit.

  3. #3
    okay, so I changed that to int main(), but how do I start the array????

    And when I compile it is telling me.... some of these....
    'Enter' : undeclared identifier
    : error C2146: syntax error : missing ';' before identifier 'the'
    : error C2065: 'the' : undeclared identifier
    : error C2146: syntax error : missing ';' before identifier 'Name'
    'Age' : undeclared identifier

    I don't understand why it is saying it is undeclared....didn't I declare it by using
    char Name...etc.????

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Create random array
    By Hunter_wow in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2007, 05:29 AM
  3. How to create multi-dimension string array
    By mihu in forum C Programming
    Replies: 2
    Last Post: 04-02-2006, 10:09 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM