fork download
  1. #include <iostream>
  2.  
  3. int* doNotDoThis()
  4. {
  5. static int x = 0;
  6. x++;
  7.  
  8. return &x;
  9. }
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13. int* a = doNotDoThis();
  14. int* b = doNotDoThis();
  15.  
  16. std::cout << (*a) << " " << (*b) << std::endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
2 2