fork download
  1. #include <stdio.h>
  2.  
  3. void parse_tgt_mac(char unformatted_mac[], unsigned tgt_mac[]){
  4. sscanf(unformatted_mac, "%x:%x:%x:%x:%x:%x", &tgt_mac[0],&tgt_mac[1],&tgt_mac[2],&tgt_mac[3],&tgt_mac[4],&tgt_mac[5]);
  5. }
  6. int main(void){
  7. unsigned tgt_mac[6];
  8. parse_tgt_mac("AA:BB:CC:DD:EE:FF", tgt_mac);
  9. for(int i = 0; i < 6; ++i){
  10. if(i)
  11. putchar(',');
  12. printf("0x%02X", tgt_mac[i]);
  13. }
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
0xAA,0xBB,0xCC,0xDD,0xEE,0xFF