Go Back   CodeCall Programming Forum > Software Development > C and C++
Register Blogs Search Today's Posts Mark Forums Read

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-17-2009, 05:19 PM
Learning Programmer
 
Join Date: Jan 2009
Location: Tennessee
Age: 24
Posts: 42
big-tony is an unknown quantity at this point
Send a message via Yahoo to big-tony
Red face 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? 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;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-17-2009, 05:29 PM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-18-2009, 04:05 AM
Programmer
 
Join Date: May 2009
Posts: 123
kiddies is an unknown quantity at this point
Re: Phone Book Program

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....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0