Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法从文件中获取标准输入并在程序运行时在控制台中显示该输入?
例如:
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