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]);
这是C++里面的处理方法
现在知道strMac 怎么用php 获取到mac
c++php

解决方案 »

  1.   


    snprintf用法Header Filestdio.hCategoryMemory and String Manipulation RoutinesPrototypeint snprintf(char* buffer, size_t nsize, const char* fmt, ...);int snwprintf(wchar_t* buffer, size_t nsize, const wchar_t* fmt, ...);DescriptionSends 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 慭0?character.
        == nsize, then nsize characters are written, with no terminating 慭0?character.> nsize, then only nsize characters are written, with no terminating 慭0?character.
    If nsize is 0, then the string will not be written to (and may be NULL).Return ValueNumber of bytes output, or, if nsize is 0, the number of bytes needed, not including the terminating 慭0?character.你想倒车回去好像不太容易,先不说超出长度会截取的问题
    $a="123";
    $b="4567";
    $c=$a.$b;
    光给你一个$c你是无法一次确定$a的内容,即使你知道规则
      

  2.   

    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]);按照这种模式得到的字符串长度是不是都一样的呢?都是16 ? %02X 按16进制输出 长度不都是2吗?
      

  3.   


    长度不一定,如果格式化后的长度小于nsize会添加一个结束符就拉倒了
    那只是个格式限制 X表示以十六进制形式输出 02 表示不足两位,前面补0输出
      

  4.   

    1、MAC地址是6个字节,可用12个十六进制数表示
    2、不知道你为什么能表示成16个十六进制数?
    3、你的 strMac 串已然是 MAC地址表示了,不知道你还要处理成什么要的