So, here is the thing. I am dissecting some code to try and better understand how to finish my project (I'm a student. Made it to the final project without getting too lost!) and I am a little stuck. This part of the code randomly fills a 32x32 2D array with 0's and 1's. The 1's are what I need to focus on. Is there a way to show a blank space instead of a 0 so you just see the 1's?

Here is the array parts of the code! If you need to see more of it I can supply it! Didn't want to violate the "don't drown us in code" part right off the bat!

for(int i=0;i<steps;i++){

	return 0;

int fillArray(){ // fills the array with random cells. everything is a zero or a one.
	int random=0;

	for(int i=1;i<=size-1;i++){
		for(int j=1;j<=size-1;j++){

return 0;

int printArray(){
    //print all the stuff that's been pushed into our array
    for(int i=0;i<=size;i++){
		for(int j=0;j<=size;j++){
            printf("%d ",grid[i][j]);


  return 0;

yes using a condition loop :

for(int i = 0; i < size; ++i){
 for(int j = 0; j < size; ++j){
    if(grid[i][j] == 0) cout << " ";
    else cout << grid[i][j];
 cout << endl;

in your loop you go from i = 0 to i <=size; Make sure you array is of size, size+1 for that loop to be correct, or else you a bug

Hello thecodepixie,
In the for loop in line 37 use some if-else statements. For example

{printf(" ");
{printf("%d ",grid[i][j]);

Edited 5 Years Ago by Arbus: n/a

This article has been dead for over six months. Start a new discussion instead.