#include <iostream> using namespace std; int main() { int a[2][13] ={ {90, 23, 26, 31, 50, 71, 39, 31, 61, 80, 11, 20, 41}, {50, 31, 29, 31, 50, 31, 30, 61, 34, 70, 38, 90, 41}, }; cout << *a[2][8] <<endl; return 0; } ----------- my Dev-C++ says ... invalid type argument of `unary *' if i use cout << a[2][8] <<endl; , it says 207744 why is this ? plz help~~~~ thx.
You don't have any value at 2,8 and so its saying you as some garbage value but the solution is not to use the * operator as that is only applicable when you have some address.
firstly since you have declared your array as a[2][13] this means that you have only two 1d arrays that can individually hold upto 13 elements and you must know that array indexing starts from 0 not 1, thus when u say a[2][8] you are saying that give me the element at position 8th in my third 1d array(which is not there) and since there are no bounds checking performed in c++ you get a garbage value instead of that you should just say a[1][8] to get the desired value and there is no need to use the indirection operator. Also if you do want to use the indirection operator the correct way is *(*(a+1)+8)