I am not sure how to phrase this. But I have a C Program that will call another C Program in unix. After the call, the program(foo-exe) will prompt for an input "Y/N". I would like to suppress(hide) this prompting message and enter 'Y' thereafter as input. How do I go about doing that?
int main(int argc, char* argv)
// do some other stuff
char ans = 'n';
printf("prompt message. Yes or no? (Y/N) ");
if(ans == 'Y') system("foo");
If that's all (Y or N) the
foo-exe expects then you could redirect its stdin to read from a pipe.
system("echo Y | /home/xyz/foo-exe bar");
But be aware of the pitfalls of
system() and its use is generally discouraged.