I've been trying to do this but I wasn't able to find any good source for it.
Basicly, I want to convert a char* variable (byte array) into an int and vis-versa. Thanks.
I've been trying to do this but I wasn't able to find any good source for it.
Basicly, I want to convert a char* variable (byte array) into an int and vis-versa. Thanks.
To convert from string to integer you can use atoi function and sprintf to do it in other direction.
UPDATE (see comments):
Than you need to do following
char *word = "Hello world";
int ints[11];
for(int i=0; i<strlen(word); ++i)
ints[i] = (int)word[i];
char data type is actually an 1 byte integer value [0,255]. So you can cast char to int and back.If you're trying to convert a byte array into an int it is sufficient to use a reinterpret_cast. Technically, this is UB, but if you know the bytes are in the right format, it usually results in exactly what you're asking for.
This is while noting the difference between a char* STRING and a char* BYTE ARRAY.