所以,我被python宠坏了,我想再次拿起C。 我得到了这个段错误,我想我明白了原因,但不确定它为什么会发生。
long head = 1; // atleast that is what I was hoping for..
long *localranks = (long*) malloc(n * sizeof(long)); // size_t n = 50;
localranks[head] = 0; // seg fault here..
printf("head is %lu %d\n", head, head);
给出head is 4294967297 1
所以,虽然头应该是1 ..我猜,它正被传递给那个垃圾值.. 我该如何解决这个问题?