Originally Posted by
jimblumberg
Why are ou using an ifstream? Your instructions state you can't use "file" operations. You need to read the input from std::cin.
The ifstream is just temporary. At least to read the text file correctly. But here is one that does use cin in it with a commandline argument. Should this be the model I should use?
Code:
void PL(std::istream& is) {
string line;
while(is) {
cout<<"Type line now";
if(std::getline(is,line)) {
// supposed to Parsing string into words and translate//
//but just reading back input for now//
cout<<"You typed:"<<line<<endl;
}
}
}
int main(int argc, char* argv[]) {
std::istream* input = &std::cin; // input is stdin by default
if(argc > 1) {
// A file name was give as argument,
// choose the file to read from
input = new std::ifstream(argv[1]);
}
PL(*input);
if(argc > 1) {
// Clean up the allocated input instance
delete input;
}
return 0;
}