The code is the following. The reason I'm using void * args
is because this function has to be used in a threaded program. It was tested with and without any threads, and it doesn't work in any of both workflows. I'm pretty new to C and this might be obvious to the average programmer but even with gdb I can't find the problem.
void arg(const void* args) {
char* arr = (char*) args;
printf("%s", arr[0]);
printf("%s", arr[1]);
return;
}
int main (void) {
char* a[2] = {"Hello", "World!"};
arg((void*)a);
return 0;
}
The above code will segfault when dereferencing args
.