-
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);
)
-
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.
-
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.????