I want to write a " C" code to convert char array into unsigned char array. Actually I want to write a function. How can I do this. I tried with google but it's not work for me. Please help.
Thanks for the code . But in my case I can't use malloc, new functions. Because This is a POS terminal application. I also have this code but it's not good. Sometimes it works sometimes not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int charToByteArray(unsignedint bytearray[],char *hexstring){
int i;
uint8_t str_len = strlen(hexstring);
memset(bytearray, 0x00, sizeof(bytearray));
for (i = 0; i < ((str_len / 2)-1); i++) {
sscanf(hexstring + 2*i, "%02x", &bytearray[i]);
}
return 1;
}