I have two values, 0 and 30, I need to store it's binary representation on one byte for each. Like:
byte 0 = 00000000
byte 1 = 00011110
and then concatenate them on a string that will print the ASCII for 0 (NULL) and for 30 (Record Separator). So, not print "030", but something I can't really right here and neither the command can print properly. I know those are not nice things to print.
I was doing like this:
string final_message = static_cast<unsigned char>(bitset<8>(0).to_ulong());
final_message += static_cast<unsigned char>((bitset<8>(answer.size())).to_ulong()); // where answer.size() = 30
cout << final_message << endl;
Not sure if it's right, I never worked with bitset since now. I think it's right but the server that receives my messages keep telling me that the numbers are wrong. I'm pretty sure that the numbers I need are 0 and 30 on that order, so, as the only part I'm not sure how it works are those three lines, I'm putting this question here.
Those three lines are right? There's a better way to do that?