This is my C program
int main(){
int n;
while(1){
printf("Enter n:\n");
scanf("%d",&n);
switch(n){
case 1: int t;
scanf("%d",&t);
if(t<10)
printf("true");
else printf("false");
break;
case 2: char c;
scanf("%c",c);
if(c=='a') printf("true");
else printf("false");
break;
case -1: break;
}
if (n==-1) break;
}
return 0;
}
This is my bash shell script
./a.out << 'EOF'
1
4
2
b
-1
EOF
This will execute the code but doesn't save the output
./a.out > outputfile
The above code will save the output, including "Enter n".
I want to execute the code and save only true/false part (i.e excluding all the other printf's). How to store the output of a file along with giving inputs to it?