char hexDigit(unsigned char n) { if (n < 10) { return n + '0'; } else { return (n - 10) + 'A'; } } void hexify_ascii(char c, char * buf) { char high = (c >> 4) & 0xF; char low = c & 0xF; *buf = hexDigit(high); *(buf + 1) = hexDigit(low); } void printHex(char* input, int len) { char buf[200]; char* p = buf; int i; for (i = 0; i < len; ++i) { hexify_ascii(input[i], p); p+=2; } *p = 0; uart_print(buf); // printf("%s\n", buf); }
Hex to C String
In case, you do not have sprintf or atoi and etc. Not efficient but works.
Subscribe to:
Post Comments (Atom)
1 comment:
c programming sample for students
c code - Create temporary file
Post a Comment