Originally Posted by flp1969 Assuming this "string" is a MAC address (6 bytes): Code: union { unsigned int dw; unsigned char b[8]; } u = { 0 }; // str points to string... if ( sscanf( str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &u.b[5], &u.b[4], &u.b[3], &u.b[2], &u.b[1], &u.b[0] ) != 6 ) { ... error ... } ... Now you can use u.dw as john.c showd above. Yes, that's exactly what it is, a MAC address. Thanks!
union { unsigned int dw; unsigned char b[8]; } u = { 0 }; // str points to string... if ( sscanf( str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &u.b[5], &u.b[4], &u.b[3], &u.b[2], &u.b[1], &u.b[0] ) != 6 ) { ... error ... } ...
View Tag Cloud