Grading Program - Compile/executing C++ code within C++

前端 未结 2 1206
轮回少年
轮回少年 2020-12-20 07:14

I am writing a program to grade C++ code that students submit. Right now it uses a system call to compile every source file then redirects the input to a file and calls the

相关标签:
2条回答
  • 2020-12-20 07:30

    I can't think of other way in C/C++ to run an external executable without using a system call (directly or indirectly).

    You may consider using Perl/Python instead of coding C++ to do such checking/automation.

    EDIT:

    Since you started scripting in Perl, you may want to look at:

    http://perldoc.perl.org/functions/exec.html

    http://perldoc.perl.org/Shell.html

    http://perldoc.perl.org/functions/system.html

    http://www.perlmonks.org/?node_id=78523

    How can I run a system command in Perl asynchronously?

    How can I terminate a system command with alarm in Perl?

    0 讨论(0)
  • 2020-12-20 07:44

    You may want to run the programs under an alternate account, e.g. ssh with key-based authentication is a good way to switch to a dummy account.

    If any of the assignments require user interaction, then expect (which is Tcl-based) would be a good choice.

    0 讨论(0)
提交回复
热议问题