A question about for loops in C

Discussion in 'OT Technology' started by PCnPROUD, Oct 5, 2005.

  1. PCnPROUD

    PCnPROUD New Member

    Joined:
    Apr 16, 2002
    Messages:
    20,653
    Likes Received:
    0
    Location:
    Garden of Weeden
    how could i have a variable within the for loop whose name includes the counter value? for example:

    for( i=0; i<num_threads; i++ )
    {
    ....iret[i-value] = pthread_create( &thread[i-value], ....);
    }

    so at each iteration i would have iret0=..., iret1=..., iret2=... etc
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    You can't have iret0, iret1, ... magically appear for each iteration of the loop. Just use the array as it is now.
     
  3. PCnPROUD

    PCnPROUD New Member

    Joined:
    Apr 16, 2002
    Messages:
    20,653
    Likes Received:
    0
    Location:
    Garden of Weeden
    wow talk about a brain freeze
     

Share This Page