开发者

How to pointing a structure in procedure in C?

I have a structure like this

typedef struct{
   int stat;
}dot;

And I would like to acces this structure in a procedure like this

void change(dot *stat){
    stat[5][5].stat = 5;
}

int main(){
    dot mydottes[10][10];
    mydottes[5][5].stat = 3;
    change(&mydottes);
    return 0;
}

But when I compiled this, it return errors. So how to pointing a structure in a procedure?

Bes开发者_StackOverflow中文版t Regards

(sorry for my bad english)


Change your code as follows:

void change(dot stat[][10]){ // <<<
    stat[5][5].stat = 5;
}

int main(){
    dot mydottes[10][10];
    mydottes[5][5].stat = 3;
    change(mydottes); // <<<
    return 0;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜