How do you convert a MAC address (in an array) to string in C? -


how convert mac address within int array string in c? example, using following array store mac address:

int array[6] = {0x00, 0x0d, 0x3f, 0xcd, 0x02, 0x5f}; 

how convert string, "00:0d:3f:cd:02:5f"?

you this:

char macstr[18]; int array[6] = {0x00, 0x0d, 0x3f, 0xcd, 0x02, 0x5f};  snprintf(macstr, sizeof(macstr), "%02x:%02x:%02x:%02x:%02x:%02x",          array[0], array[1], array[2], array[3], array[4], array[5]); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -