string convert_binary_to_hex(string binary_value)
{
bitset<8> set(binary_value);
cout << hex << set.to_ulong() << endl; // this is the output that I want to store to a variable to return
return "";
}
I've not really done C before. =D
EDIT: a user suggested ostringstream:
ostringstream result;
bitset<8> set(binary_value);
result << hex << set.to_ulong() << endl;
return result.str();
but it now give this error:
main.cpp:20: error: aggregate ‘std::ostringstream result’ has incomplete type and cannot be defined
Also, my imports:
#include <stdio.h>
#include <iostream>
#include <string>
#include <bitset>
using namespace std;