I have a class Figure and from that class I have derived basic figures in chess (pawn, king, etc). I need to simulate a chess board so I created an array as:
Figure* chess[8][8];
I did that so that the chess board will be at first uninitialized (it points to address 0xccccccc). In my program I initialize some spaces with pawns etc. But if i try to writte a loop to print out all the positions of pieces it reports an error because it tries to read from invalid location (0xcccc). I tried with if statement:
if(chess[i][j]!=NULL) { print();}; //exemple function
so that if it comes to unitialized space to ignore it but it doesn't work.
My guess is that i didn't check the adress of chess pointer correctly, but I don't know any other way.
if invalid pointer is equal to 0xcccccccc, then to check if a pointer is invalid, compare it to 0xcccccccc, not 0.
Though you should use 0 for invalid pointers. That's standard. Also, 0xcccccccc may actually point to something you need.