Convert RGB to Hex Color using C++

std::snprintf function

#include <iostream> int main() { int r = 128; int g = 96; int b = 194; char hexColor[8]; std::snprintf(hexColor, sizeof hexColor, "#%02x%02x%02x", r, g, b); std::cout << hexColor; return 0; }

Leave a Comment

Cancel reply

Your email address will not be published.