|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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;
}
|
|
||||
|
Re: Phone Book Program
You aren't subscripting your myphonebook array on your scanf()'s
__________________
CodeCall Blog | CodeCall Wiki | Shareware Programming is a branch of mathematics. My CodeCall Blog | My Personal Blog |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [HELP] C++ program that will ask the user to enter not greater than to 15 numbers | Kyram143 | C and C++ | 8 | 12-16-2009 02:53 PM |
| Tutorial: Starting C# with C# 2008 Express Edition | Jordan | CSharp Tutorials | 20 | 07-27-2009 05:45 AM |
| Debugging a C++/C File with GDB Debugger | awesome001 | C and C++ | 2 | 01-01-2009 08:07 PM |
| Error on My Basic Program Copied from Programming Book | kidcash | General Programming | 6 | 01-30-2008 12:03 PM |
All times are GMT -5. The time now is 11:18 AM.
Amrosama.cc
Arekbulski.cc
Debtboy.cc
Guest.cc
Jaan.cc
James.cc
Mathx.cc
Tsz.cc
Vswe.cc