C++ Casting a byte binary value into a string -
How do I show 6 bytes in a mac address in a string that displays the address as a hex value separated by colon is?
Thank you
You probably want a sequence of six bytes such as: < The first byte is formatted in / p>
aa: bb: cc: dd: ee: ff
where aa
is in hex.
Do something like this:
Four Macs [6]; // & LT; I'm assuming that the actual content in it is std :: ostringstream ss; (I! = 0) SS & lt; & # 39; & # 39; & # 39; ss.width (2); // & lt; for everybody (for int i = 0; i & lt; 6; ++ i); Use two letters for byte ss.fill ('0'); // fill with '0' if the number is only one hexadecimal digit SS
If you want to style it in the style of an artist (here's guessing your title ), You can create a Mac class, apply ostream operator to it (like my E-code) and boost :: lexical_cast
.
Comments
Post a Comment