arrayscfunction-callinteger-arithmeticsubscript-operator

What does mean ARR in the half place in C?


I have code :get_transaltion(&(arr[1/2]) ) The array is of structures that each contain an array of 3 places, which places does the function accept?

I edited the array in the first place in the structure with an array of 3 places and I didn't get what I edited

struct vector { 
  float data[3]; 
};
arr[1 / 2u].data[0] = 1 + 0.1;
arr[1 / 2u].data[1] = 1 + 0.2;
arr[1 / 2u].data[2] = 1 + 0.3;

Solution

  • The result of the / operator is the quotient from the division of the first operand by the second.

    Here:

    arr[1 / 2u].data[0] = 1 + 0.1;
    

    1 / 2u evaluates to 0. So it's equivalent to writing:

    arr[0].data[0] = 1 + 0.1;