评分程序 - 编译/执行c ++中的c ++代码 [英] Grading Program - Compile/executing c++ code within c++

查看:165
本文介绍了评分程序 - 编译/执行c ++中的c ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个程序来评分学生提交的c ++代码。现在,它使用系统调用来编译每个源文件,然后将输入重定向到一个文件,并在进程中调用新的可执行文件,并在输出中搜索某些字符串。这也允许我对程序崩溃的进程超时。



有没有更好的方法来做这个比系统调用?

解决方案

您可能希望在备用帐户下运行程序,如果任何分配需要用户交互,那么 expect

/ code>(这是基于Tcl的)将是一个不错的选择。


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 new executables in processes and searches the output for certain strings. This also allows me to have a timeout on processes for programs that crash.

Is there a better way to do this than a system call? Or a better way to do this in general?

解决方案

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.

这篇关于评分程序 - 编译/执行c ++中的c ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆