Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import re
  5. import subprocess
  6.  
  7. cpp_skeleton = """\
  8. #include <iostream>
  9. using namespace std;
  10. int main()
  11. {
  12. /*![prog]*/;
  13. }"""
  14.  
  15. print("### Debug1: {}".format(sys.argv[1:]))
  16. cpp_program = cpp_skeleton.replace("""/*![prog]*/""", sys.argv[1])
  17. print("### Debug2: {}".format(cpp_program.replace("""\n""", " ")))
  18. cpp_file = open("temp_pycpp.cpp","w")
  19. cpp_file.write(cpp_program)
  20. cpp_file.close()
  21. subprocess.check_call("g++ -std=c++14 temp_pycpp.cpp -o temp_pycpp.out", shell=True)
  22. subprocess.check_call("./temp_pycpp.out", shell=True)
  23. print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement