这个问题可能有点难以描述。例如,一个程序从 stdin
接收一个字符串,但它需要用户进行交互式输入,像这样:
echo "Some text to handle later after command is specified" | a.out
在程序的开头:
printf("Please input command first");
scanf("%s", &cmd);
/* Some Code Here */
/* process "Some text to handle later after command is specified" */
有没有办法“暂停”之前的输入流,等待
scanf
输入?