Thread: Searching an array with pointers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It sounds like all you have to do is call it four times to check for four different things:
    Code:
    search( array, size, 10 );
    ...two more...
    search( array, size, 11 );
    Call the same function multiple times with different key values. (Assuming the key value, the last parameter, is what you're looking for.) Naturally you'll need to check the return value of the function, I omitted that step.
    [edit]
    Here is an example:
    Code:
    int myfun( char *s )
    {
        printf("%s", s );
        return 0;
    }
    
    int main( void )
    {
        myfun( "Hello " );
        myfun("there, " );
        myfun("how " );
        myfun("are " );
        myfun("you?\n" );
        return 0;
    }
    That's what they mean by using the same function more than once without changing its signature. You're calling the same function over and over, you're just passing it something different each time. In your case, you're just changing what you search for.
    [/edit]

    Quzah.
    Last edited by quzah; 03-23-2004 at 04:00 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. two-dimensional dynamic array of pointers to classes
    By Timo002 in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 06:18 AM
  2. how do i declare array of pointers to base clase reobject
    By icantprogram in forum C++ Programming
    Replies: 3
    Last Post: 12-20-2002, 02:30 AM
  3. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  4. Loading an array using pointers
    By cheesehead in forum C++ Programming
    Replies: 5
    Last Post: 12-10-2001, 05:23 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM