#include <ctype.h> #include <stdint.h> void main(void) { uint8_t str[] = "7F3D"; uint16_t x = 0; uint8_t *p = str; while (*p) { if(isdigit(*p)){ x = x*0x10 + (*p-'0'); }else if(islower(*p)){ x = x*0x10 + (*p - 'a' + 10); }else{ x = x*0x10 + (*p - 'A' + 10); } p++; } }
|