Thursday 15 September 2011

c - What is the difference between (int*) arr[2] and int* arr[2]? -


What's with the [int *] arr [2] typecasting? If so, where is it used?

This problem arose when I tried to compile the follwing code:

  int * arr [2]; Int arr1 [] = {1,2}; Int arr2 [] = {1,6}; Arr [0] = arr1; Arr [1] = arr2;   

instead of

  int [2] with (int *) arr [2]   

Thank you.

first creates a arr int as an array of pointers Your arr is a variable, it's an announcement line.

The second one: It is believed that arr is an array (which is completely declared!), Assumes arr [2] And type pointer to int to type it on.

No comments:

Post a Comment