I started with C++ and I have to say that I never really liked the language. Python is easy to use in comparison — it has so many convenience methods and functions:
hexstring = "48656c6c6f20746865726521"
print(bytearray.fromhex(hexstring).decode())
This outputs:
Hello there!
The C++ equivalent is:
#include <stdio.h>
int main ()
{
char hexdata[] = "48656c6c6f20746865726521";
char bytedata[20]{};
for(int j = 0; j < sizeof(hexdata) / 2; j++) {
sscanf(hexdata + j * 2, "%02hhX", bytedata + j);
}
printf ("%s -> %s\n", hexdata, bytedata);
return 0;
}
Any slight error in the "pointers" used in the above functions can overwrite completely irrelevant areas in memory, causing at best a corruption of variables. Some features of the very latest releases of C++ try to give you ways to avoid the worst of these problems, but I find that the "embedded" C++ versions that I have to use with microcontrollers tend to be the 2003 version of c++ at best.