giripp
giripp

Reputation: 385

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?

Best Regards

(sorry for my bad english)

Upvotes: 0

Views: 97

Answers (1)

Paul R
Paul R

Reputation: 213059

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;
}

Upvotes: 1

Related Questions