This code return me "in printf" only ID2[0],ID2[1] and the first "character" of ID2[2]. Where is the problem ?
#include <stdio.h>
#include <string.h>
char *getMAC(char *buf, int ID[6]);
int main() {
int ID2[6]={0x00, 0x0d, 0x3f, 0x8d, 0x07, 0x3a};
char mac[18];
getMAC(mac,ID2);
printf("MAC:%s", mac);
return 0;
}
char *getMAC(char *buf,int ID[6])
{
snprintf(buf, sizeof(buf), "%02X%02X%02X%02X%02X%02X",
ID[0],ID[1],ID[2],ID[3],ID[4],ID[5]);
return buf;
}
I have like MAC:000D3F8.