Benny
Benny

Reputation: 498

Colored output to screen in C

I've wrote this very basic code-lines with colored output:

printf("\033[1;32m"); // boldgreen code: \033[1;32m according to: 
                         http://web.theurbanpenguin.com/adding-color-to-your-output-from-c/
puts("Enter username:");
gets(user);

In my computer evreything works fine and I get colored output as expected: enter image description here

but in other computers I get this Output:

\033[1;32mEnter username:

I have to say that all my #includes are fine, Im just doing copy-paste to another computer & if thats important Im using Visual Studio in both Computers.

seems like basic thing but I don't understand why thats happend. Thanks for helpers.

Upvotes: 2

Views: 410

Answers (1)

Tyler Durden
Tyler Durden

Reputation: 11532

Most terminals support colors. The problem is sending the right escape code. For the Windows command line, you have do a different escape sequence. There is a wikipedia entry that describes how to do an escape in different environments.

Upvotes: 2

Related Questions