I have a small problem converting code from java to C++
I am trying to check if a 2d array is set ,this is my java code
for(int area_y = y -1 ;area_y > 0 ;area_y--)
{
for(int area_x = 0 ;area_x < x; area_x++)
{
if(area[area_x][area_y] == 0)
{
System.out.print(" "); // this is printed
// if area[area_x][area_y] is not set
}
else
System.out.print(area[area_x][area_y]);
}
System.out.println();
}
and this is my c++ code and this works
for(int area_y = y -1 ;area_y > 0 ;area_y--)
{
for(int area_x = 0 ;area_x < x; area_x++)
{
if(area[area_x][area_y] == 0) // this line does not work as
// the next line is not executed
{
cout << "1";
}
else
cout << (area[area_x][area_y]) ;
}
cout << endl;
}
The problem is with checking if that varaible is set, it is a char area[20][50];
how can I properly check if a variable is empty (not set) in c++ ?