I’m using a web based application to grade a C program submitted by a student. For some questions, I would like the student to fill a code in a function. The following is an example screen that the student will see.
go() {
---------------------------------
| |
| |
| |
---------------------------------
}
main() {
go()
}
The student should fill some code inside a box. However, I don’t want the student to create a new function like this:
go() {
---------------------------------
| go_help(); |
| } |
| go_help() { printf("hi"); } |
---------------------------------
}
main() {
go()
}
How can I prevent the student to create a new function? The code template together with the code filled by the student will be sent to the queue waiting to be compiled and run by the server. I cannot change or check the code in that queue. The only thing I can do is to change the code template.
I think catching this at compile time will be very difficult (if not impossible). However, I you’re willing to settle with a runtime error, the following might work (tested on GCC):