dimanche 1 novembre 2020

Accessing the 2-D array( integer and character array)

Please consider below code:

char arr[3][10]={"white","red","blue"};
cout<<arr[2];  //output 1
int brr[3][3]={1,2,3,4,5,6,7,8,9};
cout<<brr[2];  //output 2

cout<<*brr[2];

Output 1 : white, on dereferencing it gives w as output

Output 2 : hexadecimal address(0x28.....)

Output 3 : Last row first element 7

I am confused why there is difference in output in array of integers and characters.

Aucun commentaire:

Enregistrer un commentaire