I want to write a simple shell script to automate running 5 test cases for a C program that prints the 3 inputted integers in ascending order.
My shell script looks like:
./a.out << 15 25 97
./a.out < 73 36 12
./a.out < 43 15 99
./a.out < 100 100 100
./a.out < 37 150 37
Clearly, this is wrong because I have been playing around with the syntax and trying different things to see what works but I hope it is clear what I am trying to do here -- Just running the program with 3 different integer inputs every time.
The one method that I tried and worked is putting each of my test cases in a text file but it seems like a bit of a hassle to do that if I want to change the input every time. Looking for a simpler concise solution.
The input reading snippet of the C program is:
int main() {
int m, n, p;
//Read m, n, p
printf("Give values of m, n and p = ");
scanf("%d%d%d",&m,&n, &p);
The values of m, n and p are then used for calculation.
./a.out 54515 25 97provide any information that1 2 3doesn't? Does your code depend on the magnitude of the numbers?atoi, where you can convert the string to an integer. However, you forgot to declare the arguments to yourmainfunction. This is discussed here