简体   繁体   中英

Mac Address c++ osx

I need to have access to my mac address using C++ . I've already found some source codes but they're all in objective-c or C# .
Is that possible to make? My environment is osx using xcode .

Thanks!

[UPDATE]

I've found this code: Get Mac Address C++

It works both on OSX and Linux. Thanks!

You could do something like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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