Dear all,
Forgive me for posting two threads for the same problem. I was not showing my problem clearly enough in the previous one. Thank Narue for answering that anyway. Now I do it again here:
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
string inputStr;
while (true)
{
getline(cin, inputStr);
if (inputStr == "quit") break;
cout << inputStr << endl;
}
return 0;
}
This programme runs fine when I compile and click the executable. But things go wrong if I do it in command-line and redirect the input stream to a text file:
$a.out < inputFile
*The programme does not let me do any input and it loops again and again instead.* I guest this is a problem associated with getline() function.
So what do you think about this?
Jim