i have declared

char arr[10][10];

and did this:

        arr[i] = (char)i;                      

but it wouldn't work..
i want to put the number inside the array.. y does this error?

7 Years
Discussion Span
Last Post by prvnkmr449

You have a two dimensional array, so you need to dereference it twice.

arr[i] = (char)i; // wrong. arr[i] is an address, not a char.
arr[i][0] = (char)i; // right.  now it's a char.

VernonDozier is correct

If we go though the structure of array
It lock some thing like this

int num[2][3];

| num[0][0] | num[0][1] | num[0][2] | <- row 0
| num[1][0] | num[1][1] | num[1][2] | <- row 1

column 0 column 1 column 2

num[0][0] -> Representing the 1st row 1st column
num[0][1] -> Representing the 1st row 2nd column
num[0][2] -> Representing the 1st row 3rd column

num[0][0] -> Representing the 2nd row 1st column
num[0][1] -> Representing the 2nd row 2nd column
num[0][2] -> Representing the 2nd row 3rd column

and you try to access array index like this

num[i]=(char)i; //arr[i]=(char)i; in your code

which is not representing any particular memory location to store data

Best Of Luck

Edited by prvnkmr449: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.