4
For example, I want print on the same screen:
printf(".___. .___. .___.\n");
printf("._1_. ._2_. ._3_.\n");
printf("Digite 0 p/ sair ou outro número p/ continuar: ");
but I want the letters of each printf
stay with different colors, for example: first blue, then green and then yellow... I tried to use the following code:
system("color A");
printf(".___. .___. .___.\n");
system("color E");
printf("._1_. ._2_. ._3_.\n");
system("color 7");
printf("Digite 0 p/ sair ou outro número p/ continuar: ");
But it didn’t work; he took only the last color, or rather, he was fast and only performed visibly the last color... I tried too:
#include <conio.h>
textcolor(blue);
printf(".___. .___. .___.\n");
textcolor(red);
printf("._1_. ._2_. ._3_.\n");
textcolor(yellow);
printf("Digite 0 p/ sair ou outro número p/ continuar: ");
But it says that textcolor
was not declared.
Boy,
conio
is obsolete too many... How about that answer in the Soen?– Renan Gomes
didn’t work, just printed a lot of strange character, this I think is for Unix (Linux)
– Leonardo
ops, windows right here.
– Renan Gomes
It worked, but it’s kind of complicated kk because I can’t use function, I’ll have to use the system("color XX") same, but thanks to the tip, in other projects I use this
– Leonardo
Try it if your screen does "ANSI escape sequences":
printf("\x1b[32mHello\n");
– pmg
If you’re on Windows, maybe try ansicon work (never tried)
– pmg
These only work on Linux, and ansicon only changes the cursor etc
– Leonardo