I need to score my students c programming homeworks. I want to write an autograder script which automatically score the homeworks. I plan to write this script in python language.
My question is, in the homework, in some parts students get some input from keyboard with scanf, how can i handle this problem if I try to write an autograder?  Is there any way to read from text file when the scanf line runs in homework ? 
Any idea is appreciated.
You can use the subprocess module in Python to spawn other programs, retrieve their output and feed them arbitrary input. The relevant pieces will most likely be the Popen.communicate() method and/or the .stdin and .stdout file objects; ensure when you do this that you passed PIPE as the argument to the stdin and stdout keywords on creation.
Autograder script - reading keyboard inputs from textfile