I just started using visual c++ have an idea for an easy game and would like to know wether there is a simple way to display a 2d array on screen as a graphical output I already tried many librarys but there were somehow too complicated. But however I am not interested in having an character box thanks.
-
[Windows GDI](https://msdn.microsoft.com/en-us/library/windows/desktop/dd145203(v=vs.85).aspx) – 001 Jun 27 '16 at 14:22
-
1SDL2 and SFML are good libraries. If you want just text, you can use iostream. If you want just text but with some extra features, there's curses. To get a good answer, you'll have to edit the question and give more details. – Ivan Rubinson Jun 27 '16 at 14:24
-
Yes Windows GDI is the way, also take a look at [Display an array of color in C](http://stackoverflow.com/a/21699076/2521214) – Spektre Jun 28 '16 at 04:59
-
I think "display a 2d array" is too vague. Array of what? A bitmap image is a 2d array of pixels. Excel is a 2d array of cells. Do you mean that the output is graphically a grid? Or do you mean that the source data just happens to be stored in a 2-dimensional array? A ListView control might do the trick in the general case. – Wyck Jul 07 '16 at 02:40
2 Answers
There really is no simple solution.
There are some libraries out there which can make your life easier. The drawback is that you have to learn how these different libraries work. If you want to make a simple game in C++ that's what you have to do.
Some libraries would be:
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.
SFML provides a simple interface to the various components of your PC, to ease the development of games and multimedia applications. It is composed of five modules: system, window, graphics, audio and network.

- 2,610
- 2
- 20
- 36
For simple, out-of-the-box text console output:
#include <iostream>
int main()
{
const unsigned int ARR_LENX = 5;
const unsigned int ARR_LENY = 5;
char array[ARR_LENX][ARR_LENY];
Initialize(array);
for (int y = 0; y < ARR_LENY; ++y)
{
for (int x = 0; x < ARR_LENX; ++x)
std::cout << array[y][x];
std::cout << std::endl;
}
}

- 3,001
- 4
- 19
- 48