Snprintf () ask unsigned & nbsp; char & nbsp; * mac & nbsp; = & nbsp; (unsigned & nbsp; char & nbsp; *) & amp; macAddr; & nbsp; snprintf (strMac, & nbsp; 33, & nbsp; "% 02X % 02X snprintf () ask for advice
Unsigned char * mac = (unsigned char *) & macAddr;
Snprintf (strMac, 33, "% 02X % 02X % 02X % 02X % 02X % 02X % 02X % 02X", mac [0], mac [1], mac [2], mac [3], mac [4], mac [5], mac [6], mac [7]);
This is the processing method in C ++.
Now I know how to use php to get the mac from strMac.
C ++ php
------ Solution --------------------
Snprintf usage
Header File
Stdio. h
Category
Memory and String Manipulation Routines
Prototype
Int snprintf (char * buffer, size_t nsize, const char * fmt ,...);
Int snwprintf (wchar_t * buffer, size_t nsize, const wchar_t * fmt ,...);
Description
Sends formatted output to a buffer of a maximum length specified by nsize.
If the number of bytes to output is:
<Nsize, then all of the characters have been written, including the terminating limit 0? Character.
= Nsize, then nsize characters are written, with no terminating limit 0? Character.
> Nsize, then only nsize characters are written, with no terminating limit 0? Character.
If nsize is 0, then the string will not be written to (and may be NULL ).
Return Value
Number of bytes output, or, if nsize is 0, the number of bytes needed, not including the terminating limit 0? Character.
It is not easy for you to reverse the car. if you want to reverse the car, you should not say that it will be intercepted if the length is exceeded.
$ A = "123 ";
$ B = "4567 ";
$ C = $ a. $ B;
Just give you a $ c, you cannot determine the content of $ a at a time, even if you know the rules
------ Solution --------------------
1. the MAC address is 6 bytes, which can be expressed by 12 hexadecimal numbers.
2. Why do you have 16 hexadecimal numbers?
3. your strMac string is already represented by the MAC address. I don't know what else you want to handle it.