fork(4) download
  1. #include <iostream>
  2. #include <limits>
  3. #include <string>
  4. #include <stdio.h>
  5.  
  6. std::string itos(int n)
  7. {
  8. const int max_size = std::numeric_limits<int>::digits10 + 1 /*sign*/ + 1 /*0-terminator*/;
  9. char buffer[max_size] = {0};
  10. sprintf(buffer, "%d", n);
  11. return std::string(buffer);
  12. }
  13.  
  14. #define HERE (std::string(__FILE__) + "(" + itos(__LINE__) + "): ")
  15.  
  16. int main()
  17. {
  18. std::cout << HERE + "Hello world" << std::endl;
  19. }
Success #stdin #stdout 0.01s 2816KB
stdin
Standard input is empty
stdout
prog.cpp(18): Hello world