2
printf(" %02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char)item->ifr_hwaddr.sa_data[0],
(unsigned char)item->ifr_hwaddr.sa_data[1],
(unsigned char)item->ifr_hwaddr.sa_data[2],
(unsigned char)item->ifr_hwaddr.sa_data[3],
(unsigned char)item->ifr_hwaddr.sa_data[4],
(unsigned char)item->ifr_hwaddr.sa_data[5]);
到這個(可變店,不打印):
char mac[18];
感謝
我需要將它保存到一個變量中,而不是打印它 – shaggy
Sprintf(以s開頭)將格式化的輸出寫入char數組,而不是寫入stdout。看看stdio.h。你會發現printf,fprintf(將格式化的字符串寫入文件)和sprintf(將格式化的字符串寫入字符串)。試試我發佈的代碼。 –