0

有没有办法从文件中获取标准输入并在程序运行时在控制台中显示该输入?

例如:

std::string s;
std::cout << "Input: ";
std::cin >> s;
std::cout << "Output: " << s << std::endl;

infile.txt:

apple

./program < infile.txt 显示:

Input: Output: apple

但我希望它显示:

Input: apple
Output: apple
4

0 回答 0