fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. int main()
  5. {
  6.  
  7. bool on = false;
  8. int id = 1;
  9.  
  10. if(on == false)
  11. {
  12. on = true;
  13. std::cout << "Socket enabled!" << std::endl;
  14.  
  15. //save to disk
  16. std::ofstream onF;
  17. onF.open("Socket" + std::to_string(id) + ".txt");
  18.  
  19. if(onF.is_open())
  20. {
  21. onF << true << std::endl;
  22. onF.close();
  23. }
  24.  
  25. }
  26.  
  27. else if(on == true)
  28. {
  29. std::cout << "Socket already enabled." << std::endl;
  30. }
  31. }
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
Socket enabled!