Il 04/02/2017 23:43, Richard ha scritto:
> By "output garbage", I assume you are referring to the output of the
> program and not the output of the compilation process.
You guessed it ;) sorry I was not clear.
Compilation with minGW is ok, no warnings.
I've re-compiled your code in Visual studio and it compiles perfectly.
I don't know what went wrong that time.
But, as already reported earlier, this is what I get when running your code:
[2J
[0;0f
[0;31mH [0;32me [0;33ml [0;34ml [0;35mo [0;36m, [0;37m
[0;31mw [0;32mo [0;33mr [0;34ml [0;35md [0;36m. [0;37m. [0;31m. [0;32m
[10;30f:)...
> The Windows command processor CMD.EXE doesn't guarantee to support
> ANSI escape sequences.
OK, nor even Window 10's CMD supports it as I can see.
> There are several choices here. You can code something that is
> portable across operating systems or you can code something specific
> to Windows.
The solution using the macros _WIN32 or __linux__ worked fine.
I've tested the code on both the OSes and calling the system() routine
worked perfectly.
The most portable solution is to use the curses library
> and have it output the appropriate escape codes for the environment.
PDcurses is what I'm studying, but I don't have the necessity to manage
the console screen as individual cells. It's just fine the normal cout.
I just needed a way to clear the screen's buffer.
The game I'm trying to write is a text-driven old-style RPG. It needs a
lot of paper to sketch the corridor passages and to annote the eventual
content of a room. But this project is just a hobby, that I write from
time to time not even frequently. Probably will be never finished.
The second solution require to include the <windows.h> header. I don't
know anything about it, sorry. The first olution is the simpler and
clearer and will be that I will use.
Programming is an "art"
...and art is beauty.
So the principle I conform is KISS: "keep it simple, stuid" or "keep it
short, simple".
Regards,
Alex