Pointer to structure with massiv (how it works)

Back to General discussions forum

bobfromjungle     2018-01-24 13:51:06

Hallo ! I have pointer to structure with massiv. So on purpose to take access to value in this massiv, i have to wrote *(u->value) and it works! So I am fully dont understand how it works. Could you explain me pls.

Code for example:

typedef struct vvod {
    int n_value;
    int value[100];
} input;        
void add (input *u) {
    printf ("%i\n", *(u->value));
}
int main (){
    input recived;
    .
    .
    .
    add (&recived);
}
J_Language     2018-03-04 16:47:45

arr[i] is just syntactic sugar for *(arr + i), so your *(u->value) is equal to *(u->value + 0) and u->value[0] both.

Please login and solve 5 problems to be able to post at forum