Suppose I were to create N number of threads and I would be passing a different string into each thread.
Pseudocode:
for (i = 0; i < N; i++) {
strncpy(arg.str, some_new_str, sizeof(arg.str));
pthread_create(&threads[i],NULL,somefunc, (void *) &arg);
}
Would the string pointed to by arg in each thread change? Say for the first thread created, some_new_str is "hello" and for the second, it is "bye". Later when I print the string in thread 1, would the string be changed to "bye" instead of "hello"?
EDIT: So then I should create a new arg struct for each thread?