int a; 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 << " ";
variable = value;
MacAddr
Quote:as you can see i am displaying mac address after converting it in hex and i want to use the same format in which its being displayed through for loop mechanism i want to store it in string variable so next time i can simply print string variable on the screen
std::ostringsteam
std::cout
std::stringstream ss; for (unsigned char c : MacAddr) ss<<std::setw(2) << std::setprecision(2) << std::setfill('0') << std::hex << (unsigned)c << " "; std::string sMAC = ss.str(); cout << "\nMac address is: " + sMAC;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)