String problem mainia!

This is a discussion on String problem mainia! within the C Programming forums, part of the General Programming Boards category; hi i have this program. the question is this : Write a program that creates an array of 5 strings. ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    3

    Unhappy String problem mainia!

    hi i have this program. the question is this :

    Write a program that creates an array of 5 strings. The user is then asked to enter
    the name, address and telephone number of 5 different people into this array.

    Write a function that is capable of finding the door number, any number that
    may be included as part of the street name, the number of the post code, and the
    telephone number inside a string. It should return the telephone number that is found
    in the string.

    i am experiancing some reading the digits from the strings! been pulling out alot of hair!. no hair left! pls help?? i also have another problem, if i start inputing the string, if i press space, it skips a label! what can i possibly do? PLS HELP! crazy.gif


    Code:
    #include <stdio.h>
    #include <ctype.h>
    
    int main (void)
    {
        char string[5][100];
        int i, j;
        char *labels[] = {"Name","Address","City, State","Zipcode","Phone"};
    
        for(i=0;i<5;i++)
        {
            for (j=0;j<5;j++)
            {
                printf ("Enter %s: ", labels[j]);
                scanf("%s",&string[i]);
            }
        }
        for(i=0;i<5;i++)
        {
            if (isdigit(string))
            {
                printf("%d. %s\n",i+1,string[i]);
            }
        }
    
        return (0);
    }

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    Read the link in Elysia's signature for how to scanf spaces.

    And doesn't isdigit take a char, not a pointer? Turn up your warnings.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  2. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 02:40 AM
  3. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21