I have a string that looks like this:
str = "751CEC132EB348978013CE7AF8375137"
It is 32 characters long. I want to modify it to look like this:
{0x751CEC13,0x2EB34897,0x8013CE7A,0xF8375137}
I know that if I can split up the string into 4 groups (8 characters each) I can easily construct the required string using those groups and a stringstream.
An easy way to do this in python would be to do this:
'{0x%s,0x%s,0x%s,0x%s}'%(str[0:8],str[8:16], str[16:24], str[24:32])
How can I do this in C++? I’m not very familiar with the low level functions like “sscanf” but they sound like they could come in handy.
If the
{0x751CEC13,0x2EB34897,0x8013CE7A,0xF8375137}is a whole string, then use the following lines instead: