3

I am trying to assign certain members of a 2 dim array. Not able to get following code to work. Help would appreciated very very much.

int myArray[5][5] = {[1][1]{1},[2][2]{2},[3][3]{3},[4][4]{4}};

main()
{
  printf("%d %d\n", myArray[1][1], myArray[4][4]);
} 
4

1 回答 1

3

The way you are initializing the array

int myArray[5][5] = {[1][1]{1},[2][2]{2},[3][3]{3},[4][4]{4}};

is wrong. If you are interested in designator then initialize it as follows

int myArray[5][5] = {[1][1] = 1,[2][2] = 2,[3][3] = 3,[4][4] = 4};
于 2013-09-06T17:02:04.943 回答