Just convert the int to a string and add "0x" to the beginning of the string
int serial = 40000359;
char result[20];
sprintf(result,"0x%d", serial);
Or if you want to use only c++
#include <sstream>
#include <string>
#include <iostream>
int main()
{
int serial = 40000359;
std::string result;
std::stringstream str;
str << "0x" << serial;
str >> result;
std::cout << result << '\n';
}