RGB to HTML color

Colors

int red = 51;
int green = 255;
int blue = 51;
int alpha = 128;

//%02X: two hexadecimal digits with a leading zero
char htmlColor[10];
snprintf(htmlColor, sizeof htmlColor, "#%02X%02X%02X", red, green, blue);
//htmlColor is "#33FF33"
printf("style=\"color: %s\"\n", htmlColor);

//with transparency
snprintf(htmlColor, sizeof htmlColor, "#%02X%02X%02X%02X", red, green, blue,
         alpha);
//htmlColor is "#33FF3380"

printf("htmlColor is %s\n", htmlColor);