This bit is fine, and is in general when filling a 2d array from start through to finish.Code:int **pixel; rows = numRows; columns = numCols; pixel = new int *[rows]; for(int i = 0; i < rows ; i++) { pixel[i] = new int [columns]; for(int j = 0; j < columns; j++) pixel[i][j] = 0; }

What if I want to then fill this 2d array with meaningful data within some statements:

The code above is very rough as I do not have the problem at hand...I want to be able to fill that 2d array given a certain condition, therefore i need a way to control the i and j variables of the 2d array.Code:int i=0; int j=0; for (int x=0;x<rows;x++){ for (int y=0;y<columns;y++){ pixelvariable++; if (somecondition_true){ pixel[i][j] = *pixelvariable; if (j < (pixelColumnSize-1) j++ //THIS PART IS THE PROBLEM?? else j=0; i++; } }

Is there a better way? the above does not work at the moment.