I'm trying to just print space in my "canvas" ( with coordinates (2,2) for example) by editing my 80x20 grid made by █ blocks in the console window.
-
Please suggest me better ways of creating the grid in the first place ( I've just learned for-each loops)
-
Why do I get those 3 characters after running the program ?
-
Why isn't the space on the (2,2) block but obviously on the first row somewhere in the mid ?
Code :
#include <iostream>
int main()
{
uint8_t block {219}; // █
uint8_t space {32}; // ' '
uint8_t screen[80][20] {};
for (auto &row : screen) // make the "canvas"
for (auto &col : row)
col = block;
for (int row = 1; row <= 80; ++row)
{
for (int col = 1; col <= 20; ++col)
{
if (col == 2 && row == 2)
screen[row][col] = space;
}
}
std::cout << *screen;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire