Thread: ptherad_create pass 2 arguments to start_routine

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    1

    ptherad_create pass 2 arguments to start_routine

    Hi,
    I do not understand how to pass to arguments to the start_routine in pthread_create.
    Can anyone give me a hint?

    Example:
    Code:
    //function prototype
    void routine(int *, char **);
    
    //ptherad_create
    pthread_create(&id, NULL, (void *)routine, (int *)count);
    
    //function definition
    void routine(int *count, char **arr){}
    Thank you,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Thread functions take a single void* parameter.
    If you need to pass more than 1 param, then pass a pointer to a struct.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-22-2007, 12:58 AM
  2. How can I pass arguments through a GUI (win32)?
    By bikr692002 in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2006, 05:17 PM
  3. pass several arguments to LPVOID param of CreateThread
    By Echidna in forum Windows Programming
    Replies: 4
    Last Post: 05-05-2002, 10:18 AM
  4. Replies: 3
    Last Post: 04-02-2002, 01:39 PM
  5. Parameter pass
    By Gades in forum C Programming
    Replies: 28
    Last Post: 11-20-2001, 02:08 PM