Nik Nik - 1 month ago 25
C Question

Output bold text to console in C (on Mac - Xcode)

Lately I've been experimenting with coding basic programs in C using Xcode, and I've found myself looking for ways to italicize text or make it bold or coloured. Despite the numerous similar posts on SO, there hasn't been one to prove helpful to my situation, however I've found many examples for this in C++ (if that means anything). Perhaps it's not possible to format text in C using Xcode?

Particularly, I've read about using ANSI escape coding, but when I use this code:

, I end up with this as output:
. I believe this is because ANSI escape coding is not intended to be used on MacOS (just Linux).

Specifically, I'm looking for a way to output formatted text to the console using
or some other method that prints text to the console, on a Mac. (Is this even possible?...)

Feel free to ask for any additional information as needed.


The default internal console for XCode is not a terminal, so it doesn't interpret escape codes. As a result you don't get to see the effects of bold/color changes.

On XCode 8, there is an option to edit the scheme to get the program to run in a terminal. Click on the pop-down to the right of the stop button, and select 'Edit Schemeā€¦'

Edit Scheme Dropdown Target

Once you pop up the 'edit scheme' screen, choose options, then select run in terminal.

enter image description here

If you're just trying to get it to run from a terminal; you can launch terminal separately, then drag and drop the binary from the 'Products' section of the project navigator into the terminal (it will print out the full path to the binary in the terminal, and you can run it from there).

Colored emojis do display properly on the console; it's just that it doesn't respect color escape codes.