3d char array problem
I have to write a code to build an array like this:
1,6 1,0 2,3
3,4 5,6 4,5
7,6 1,2 9,7
Where the numbers are coordinates which have to be "separated" when taken in consideration
Like:
cell[2][2]---> x=5 y=6
I decided to make a char array, so that with atoi() I then convert it to numbers, but I cannot declare the array:
1 2
|
char iaMatrix[iSize][iSize][3]={{'1,2','1,0'}
{'1,0','6,4'}};
|
It gives me error:
missing } for lots of times.
What should I do? Thank you.
I've found it myself, I simply put ' instead of "
for anybody who may need it:
1 2 3 4 5 6 7 8 9
|
const int iSize=8;
const int iSizeChar=3;
int main(){
char iaMatrix[iSize][iSize][4]={{"1,2","2,3"}};
cout << iaMatrix[0][0] << endl;
system("pause");
return 0;
}
|
works fine.
Just remember that the size of the string (char[]) must be one more of what you need for the terminator character '\0'.
Night.
Topic archived. No new replies allowed.