I am aware of the fact that we can print colors in the terminal as mentioned here: stdlib and colored output in C and here: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
Is it possible to output more custom color with the 24-bit RGB code (r,g,b) where r,g and b goes from 0 to 255 (ideally portable but at least for a MacOS 11.6.1)? The following solutions enables 255 colors but still not with rgb coding. What I would like to be able to do is to tune 3 parameters (r, g and b) to have the desired color
// inspired from http://jafrog.com/2013/11/23/colors-in-terminal.html
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 256; i++)
{
printf("\e[38;5;%dm %3d\e[m", i, i);
}
return 0;
}