Home Backend Development PHP Tutorial snprintf() 请问请问

snprintf() 请问请问

Jun 13, 2016 am 11:14 AM
character mac nbsp

snprintf() 请教请教
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

<br />snprintf用法<br /><br />Header File<br /><br />stdio.h<br /><br />Category<br /><br />Memory and String Manipulation Routines<br /><br />Prototype<br /><br />int snprintf(char* buffer, size_t nsize, const char* fmt, ...);<br /><br />int snwprintf(wchar_t* buffer, size_t nsize, const wchar_t* fmt, ...);<br /><br />Description<br /><br />Sends formatted output to a buffer of a maximum length specified by nsize.<br /><br />If the number of bytes to output is:<br /><br />< nsize, then all of the characters have been written, including the terminating 慭0?character.<br />    == nsize, then nsize characters are written, with no terminating 慭0?character.<br /><br />> nsize, then <span style="color: #FF0000;">only nsize characters are written</span>, with no terminating 慭0?character.<br />If nsize is 0, then the string will not be written to (and may be NULL).<br /><br />Return Value<br /><br />Number of bytes output, or, if nsize is 0, the number of bytes needed, not including the terminating 慭0?character.<br />

Copy after login

你想倒车回去好像不太容易,先不说超出长度会截取的问题
$a="123";
$b="4567";
$c=$a.$b;
光给你一个$c你是无法一次确定$a的内容,即使你知道规则

------解决方案--------------------
1、MAC地址是6个字节,可用12个十六进制数表示
2、不知道你为什么能表示成16个十六进制数?
3、你的 strMac 串已然是 MAC地址表示了,不知道你还要处理成什么要的
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

No response when entering password on mac keyboard? No response when entering password on mac keyboard? Feb 20, 2024 pm 01:33 PM

No response when entering password on mac keyboard?

3 tips to easily customize your Mac computer name, host name and Bonjour name 3 tips to easily customize your Mac computer name, host name and Bonjour name Mar 06, 2024 pm 12:20 PM

3 tips to easily customize your Mac computer name, host name and Bonjour name

Forgot your mac installer password? Forgot your mac installer password? Feb 20, 2024 pm 01:00 PM

Forgot your mac installer password?

pkg file to install on mac? pkg file to install on mac? Feb 20, 2024 pm 03:21 PM

pkg file to install on mac?

How to turn pages when typing on Apple Mac? How to turn pages when typing on Apple Mac? Feb 20, 2024 pm 12:54 PM

How to turn pages when typing on Apple Mac?

vmmac virtual machine full screen (how to full screen virtual machine macos) vmmac virtual machine full screen (how to full screen virtual machine macos) Feb 20, 2024 pm 01:15 PM

vmmac virtual machine full screen (how to full screen virtual machine macos)

How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion Mar 19, 2024 am 08:28 AM

How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion

3 Ways to Convert HEIC Photos to JPG on Mac 3 Ways to Convert HEIC Photos to JPG on Mac Mar 15, 2024 pm 08:43 PM

3 Ways to Convert HEIC Photos to JPG on Mac

See all articles