I have a C program in which I use
scanf to get user input. Now, I would like to make a .sh script that automatically test this program with pre-defined user input, but I'm not sure how I can send the input every time the program needs it.
If you need to have an automated conversation with your program (i.e. want to interpret the output as well), take a look at expect. This is a tcl based tool for automating interactive sessions. It might give you what you want.