+ Reply to Thread
Results 1 to 3 of 3

Thread: Phone Book Program

  1. #1
    Learning Programmer big-tony is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Tennessee
    Age
    24
    Posts
    42

    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;
    }

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,693
    Blog Entries
    57

    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

  3. #3
    Programmer kiddies is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    123

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 8
    Last Post: 12-16-2009, 01:53 PM
  2. Tutorial: Starting C# with C# 2008 Express Edition
    By Jordan in forum CSharp Tutorials
    Replies: 20
    Last Post: 07-27-2009, 04:45 AM
  3. Debugging a C++/C File with GDB Debugger
    By awesome001 in forum C and C++
    Replies: 2
    Last Post: 01-01-2009, 07:07 PM
  4. Error on My Basic Program Copied from Programming Book
    By kidcash in forum General Programming
    Replies: 6
    Last Post: 01-30-2008, 11:03 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts