the different ways about customising console output in C++ (which one to prefer)

  ansi, c++, console, vt100

I wanted to know how can i colorising or customising console, then i found this title:
Colorizing text in the console with C++ in this title, this code suggested:

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  // you can loop k higher to see more color choices
  for(int k = 1; k < 255; k++)
  {
    // pick the colorattribute k you want
    SetConsoleTextAttribute(hConsole, k);
    cout << k << " I want to be nice today!" << endl;
  }

which needs <windows.h> library.

And then, I’ve learned new way to customising console output (I was seeking about clearing spesific line) which called "VT100 Escape Code(ANSI)" in my vision, this is more easy to use as well as no need extra library.

here is the question: What is differences between these two ways, which one should be preferred in which situation, and does it have performance differences?

Source: Windows Questions C++

LEAVE A COMMENT