creation of matrix

how to create a matrix of char type with static allocation of memory in c++ ???
i try with this code but it have a problem???
char matrice [10][10];
for ( i=0; i<n; i++ ){
for ( j=0; j<n; j++){
Just 'char matrice[10][10];' is enough.

I guess that, what you're trying to do is make sure that when you create the two-dimensional char array, is that every position is 'cleared' to begin with, but this step isn't necessary as the allocation of memory already does this for you.

When you create 'char matrice[10][10]', all of those spots will be 'cleared'.

But, if you want to fill every spot in the two-dimensional char array with the character 0, all you have to do is change matrice[i][j]=0; to matrice[i][j]='0';

Btw: Watch out when using the word 'static'. Static memory is not the opposite of dynamic memory. 'Static memory' is memoryspace that is shared by instances of the same class.
Last edited on
Topic archived. No new replies allowed.