简体   繁体   English

Mac地址c ++ osx

[英]Mac Address c++ osx

I need to have access to my mac address using C++ . 我需要使用C++访问我的mac address I've already found some source codes but they're all in objective-c or C# . 我已经找到了一些源代码,但是它们都在objective-cC#
Is that possible to make? 那有可能吗? My environment is osx using xcode . 我的环境是使用xcode osx

Thanks! 谢谢!

[UPDATE] [更新]

I've found this code: Get Mac Address C++ 我找到了以下代码: Get Mac Address C ++

It works both on OSX and Linux. 它可以在OSX和Linux上运行。 Thanks! 谢谢!

You could do something like this: 您可以执行以下操作:

FILE *fp = popen("ifconfig en0 | awk '/ether/{print $2}'", "r");
fscanf(fp, "%s", &mac);
pclose(fp);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM