I'm trying to write a simple test program that would do:
echo Hello world! | myprogram.exe
And the output would be:
I heard: "Hello world!". Message length: 12 chars.
I'm trying to write a simple test program that would do:
echo Hello world! | myprogram.exe
And the output would be:
I heard: "Hello world!". Message length: 12 chars.
Use the input stream std::cin, declared in < iostream >. The exact usage depends on your needs, i.e. you'll need different functions for reading words, characters, whole lines or maybe even all input.
I found, this is the function:
string readStdin() {
stringstream ss;
string line;
while (getline(cin, line)) {
ss << line << endl;
}
cin.clear();
return ss.str();
}