Convert Hex to RGB Color using C++

std::sscanf function

#include <iostream>

int main()
{
    int r, g, b;
    char const *hexColor = "#8060c2";
    std::sscanf(hexColor, "#%02x%02x%02x", &r, &g, &b);

    std::cout << r << ',' << g << ',' << b;

    return 0;
}

Leave a Comment

Cancel reply

Your email address will not be published.