In a C/C++ program, how can I write bold text in the terminal? [duplicate]


is it possible to format the console output, like writing in bold, of a C/C++ program? I'm talking just about the console output (so no high-level) e.g.:

std::cout << "\b this is bold";
std::cout << " this is not";

I hope there are some libraries, this program is intended for Linux.

Thanks for advises.


Answers:


That is not a question about C or C++ but rather about your particular console. Any answer is specific to your target, and possibly in Linux dependent the specific particular terminal emulator.

In most cases a terminal, terminal emulation, or in case of Windows a console window, there will be no support for bold as such - you can often control the colour and brightness of a fixed font however. You can do this in a number of ways - again platform specific - for example through a library such as curses, by sending terminal specific escape sequences, or in Windows through the Win32 Console API.

Without knowing the specific platform, it is not possible to give a specific answer, and even then that answer may not be portable to other platforms.