#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <sys/time.h> #include <unistd.h> #include <string.h> #define size 5 void *displayName(void *received_array){ char *name = received_array; for(int i=0;i<5;i++) puts(name[i]); pthread_exit(0); } int main(){ pthread_t threadid1; char name[10][50]; strcpy(name[2], "raj"); strcpy(name[3], "pol"); strcpy(name[4], "sara");*/ pthread_create(&threadid1,NULL,displayName, name); }
In function ‘displayName’: q2v2.c:42:15: warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast [-Wint-conversion] 42 | puts(name[i]); | ~~~~^~~ | | | char
You should match the type of passed pointers.
Replace
char *name = received_array;
with
char (*name)[50] = received_array;
Also don't forget to initialize name[0] and name[1] in the main() function.
name[0]
name[1]
main()
2.1m questions
2.1m answers
60 comments
57.0k users