我想知道sample1和sample2之間有什麼區別。爲什麼有時我必須將結構作爲參數傳遞,有時我可以在不傳遞函數的情況下做到這一點?如果samplex函數需要幾個結構來處理,它將會如何呢?你會通過幾個結構作爲一個論點?C Struct作爲參數
struct x
{
int a;
int b;
char *c;
};
void sample1(struct x **z;){
printf(" first member is %d \n", z[0]->a);
}
void sample2(){
struct x **z;
printf(" first member is %d \n", z[0]->a); // seg fault
}
int main(void)
{
struct x **z;
sample1(z);
sample2();
return 0;
}
太好了!謝謝(你的)信息!我有點困惑! – Brian 2010-03-24 15:52:50