fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. // Prints the MAC address stored in a 6 byte array to stdout
  7. void PrintMACaddress()
  8. {
  9. printf("00-19-D7-53-2D-14");
  10. }
  11.  
  12. // Fetches the MAC address and prints it
  13. void GetMACAddress()
  14. {
  15. PrintMACaddress(); // Print MAC address
  16. }
  17.  
  18. int main()
  19. {
  20. stringstream ss;
  21. streambuf* old = std::cout.rdbuf(ss.rdbuf());
  22.  
  23. GetMACAddress();
  24.  
  25. string theStr = ss.str();
  26. cout << theStr << endl;
  27. cout << "Hello world" << endl;
  28.  
  29. std::cout.rdbuf(old);
  30. cout << "Hello world" << endl;
  31. }
Success #stdin #stdout 0.01s 2816KB
stdin
Standard input is empty
stdout
00-19-D7-53-2D-14Hello world