pthread 内の次のコード ブロックで "Segmentation Fault 11" が発生します。
void *func(void *len){
char *temp = len;
size = (int) strtol(temp, (char **)NULL, 10); // this throws the segfault
}
pthread create は次のように記述されます。
int main(int argc, const char *argv[]){
pthread_t t0;
const char * length = argv[1];
pthread_create(&t0, NULL, &func, (void *)length);
// rest of code
...
}
私を混乱させているのは、Xcodeではなくターミナルでコンパイルして実行するとSegFaultがスローされることです。なぜそれが投げられているのか、何か考えはありますか?