0

I've a project in C++ (probably developed on linux) that I wish to run on Windows via code::blocks.

But an unexpected phenomenon happens when I try to run it. Normally, there is a grid made of # and + supposed to adopt different colors, but the only output that I have is:

###################################################################
#  [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m   [1;90m+[1;0m  #
#    [1;91m3[1;0m           [1;96m2[1;0m               [1;91m3[1;0m               [1;96m2[1;0m           [1;91m3[1;0m    #
...

somewhere in the code I can see (among others):

static const char* grey = "\033[1;90m" ;
static const char* reset = "\033[1;0m" ;

and somewhere else using this declaration in some conditions:

out << grey << "+" << reset ;

I think that you guessed the question which is: How to display the grid correctly, in color? The problem comes from the OS, from codeblocks, from the compiler?

Any way which could bring me to a solution is welcome.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Skald
  • 1
  • 1
  • 5
  • Can we assume that your OS is Windows? You didn't say in so many words. – john Apr 24 '20 at 18:08
  • its the terminal, related: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences – 463035818_is_not_an_ai Apr 24 '20 at 18:09
  • also very related: https://unix.stackexchange.com/questions/548158/in-2019-is-it-safe-to-assume-that-all-terminals-understand-ansi-escape-codes (though for linux) – 463035818_is_not_an_ai Apr 24 '20 at 18:10
  • You should be able to enable ANSI codes for your terminal, might need to dig through the settings. – shayaan Apr 24 '20 at 18:13
  • *"The problem comes from the OS, from codeblocks, from the compiler?"* -- it might be more insightful to say that the problem comes from C++ having no concept of color, nor of console output. How to get color in a console application depends upon which console you are using (a standard Windows command shell?). – JaMiT Apr 24 '20 at 19:25
  • Does this answer your question? [Color console output with C++ in Windows](https://stackoverflow.com/questions/9262270/color-console-output-with-c-in-windows) – JaMiT Apr 24 '20 at 19:27
  • @john yes, i am currently running the program on windows, and im using /bin/sh/ - c as output shell via C::B – Skald Apr 25 '20 at 22:05

0 Answers0