What's the difference between these ways of indexing a pointer to array of structs in c?

4

Is there any difference in the use of these 3 statements?

void addCliente(struct cliente *dadosCliente){
    dadosCliente[k].nome="oi";
    (*(dadosCliente+k)).nome="oi";
    (dadosCliente+k)->nome="oi";
}
void main(){
    struct cliente clientes[1000];
    addCliente(clientes);
}
    
asked by anonymous 04.02.2014 / 17:27

1 answer

14

The three ways to access a struct in an array are equivalent.

Therefore:

  • (*(a+b)).c is (a+b)->c
  • (*(a+b)).c is a[b].c
04.02.2014 / 17:31