Thread: search numbers in an inputed string [array of strings]

  1. #1
    Registered User
    Join Date
    Mar 2008

    Unhappy search numbers in an inputed string [array of strings]

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

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

    this is the qeustion. how can i search the numbers in a string, and returing a telephone number??

    pls help me out

    #include <stdio.h>
    int main (void)
    	char string[5][100];
    	int i;
    		printf ("Enter Name, Address, Tel no: ");
    		printf("%d. %s\n",i+1,string[i]);
        return (0);

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    isdigit() from ctype.h might help you. You'll have to loop through the string, perhaps some simple state machine thingy. Or even just sscanf(), just make sure you don't pull the wrong numbers out, like 123 5th street 5555.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM