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? also, how could I make it where you could put dashes in the inputted and outputted numbers without messing it up?
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; }
You aren't subscripting your myphonebook array on your scanf()'s
hello.....im newbie here...thats script not complete r8...can u give me a complete script for learn...couse i dont understand if just lil script like that....
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks