How to store MAC Address value in a variable in C++ in formatted form?

  • Thread starter Thread starter Shahzaib17
  • Start date Start date
S

Shahzaib17

Guest
i want to store the mac address in a variable retrieved from the code in the for loop mentioned below

i want it to be appended every time with : or space in every for loop iteration and to store it after converting it to string fromat so that when i read from the string variable it simply shows me the mac address value in this format 93-3C-4B-T4-3V-55

char MacAddr[6];
ULONG size = sizeof(MacAddr);
char jk;
SendARP(inet_addr(argv[1]), inet_addr(ipv4.c_str()), MacAddr, &size);
//std::cout << "Ipv4 is: "+ipv4;
std::cout << "\nThe MAC address is: ";
for (unsigned char c : MacAddr)
std::cout << std::setw(2) << std::setprecision(2) << std::setfill('0') << std::hex << (unsigned)c << " ";


Continue reading...
 
Back
Top