How to pass an array of C strings to a thread (pthreads)
<p>This is what I have so far, when I compile it I get this error:
lb54.c: In function ‘funct1’:
lb54.c:38:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
  printf("%s\n",name[i]);
  ^</p>

<p>when I change %s to %d it works,but it displays some random numbers</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;pthread.h&gt;
#include &lt;string.h&gt;

void * funct1(void* arg);
void * funct2(void* arg);

void main(){

char name[10][20];
int *id = (int*)malloc(sizeof(int)*10);

int i,x=5;

for(i=0;i&lt;10;i++){
strcpy(name[i],"name");
id[i] = i;
}

pthread_t threadid;
pthread_t threadname;


pthread_create(&amp;threadid,NULL,funct2,(void *)id);
pthread_create(&amp;threadname,NULL,funct1, &amp;name);
sleep(5);
free(id);
printf("parent thread exiting\n");

}

void * funct1(void* arg){
int i;
char *name = (char *)arg;
for(i=0;i&lt;10;i++){
 printf("%s\n",name[i]);
}
}

void * funct2(void* arg){
int i;
int *id = (int *) arg;
for(i=0;i&lt;10;i++){
 printf("%d\n",id[i]);
}
}
</code></pre>