I am trying to find the best way to fill 2D Array with a specific value. Is there any better way to loop the 2D Array? I tried memset doesn't work I tried std::fill but I doubt there is something wrong with my code.
void fillMultipleArray(int m , int n , int value)
{ int grid[m][n] ;
memset(grid, 0, sizeof(grid));
for (int i = 0; i< m; i++) {
for (int i = 0; i< n; i++) {
std::cout<< grid[m][n]<< std::endl;
}
}
}
Output
-272632896 -272632896 -272632896 -272632896 -272632896 -272632896 -272632896 -272632896
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire