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.
我正在尝试编写一个简单的测试程序来执行以下操作:
echo Hello world! | myprogram.exe
输出将是:
I heard: "Hello world!". Message length: 12 chars.
使用在<iostream> 中声明的输入流std::cin。具体用法取决于您的需要,即您需要不同的功能来读取单词、字符、整行甚至所有输入。
我发现,这是功能:
string readStdin() { stringstream ss; string line; while (getline(cin, line)) { ss << line << endl; } cin.clear(); return ss.str(); }