Phone Book Program ?

This is what I'm doing

Create a program that uses a structure array to hold contact
information for your friends. The program should allow the
user to enter up to five friends and print the phone book’s
current entries. Create functions to add entries in the phone
book and to print valid phone book entries. Do not display
phone book entries that are invalid or NULL (0).
======================================...

Whenever I compile the program I can enter 5 numbers and names however, once the results show they are ALL the same RANDOM number..

Where have I went wrong?

Here is my Code:

Code:

struct phonebook
{
char name[100];
long int phone;
};

int main()
{
struct phonebook myphonebook[5];
int i;
for(i=0;i<5;i++)
{
printf("\n Enter name of friend:-\n");
scanf("%s",&myphonebook.name );
printf("\n Enter phone number of friend:-\n");
scanf("%ld",&myphonebook.phone );
}
for(i=0;i<5;i++)
{
printf("\n Friend name %s phone number is %ld \n",myphonebook.name,myphonebook.phone);
}
return 1;
}
 
Back
Top