Need help with outputting in terminal

Hi! I was having trouble coming up with an algorithm for my program. I have a project for my comp sci class to make a game like D&D and was having trouble with one aspect. I am inputing the script from a file line by line, but don't want to output a ton of info all at once. My goal is to output a single line in the file only when the user presses a key. What would this algorithm look like to accomplish this?
So far, I have this:

ifstream myfile;
myfile.open("file.txt");

string line;

while(myfile >> line){
???
}

Any help is appreciated! Thanks in advance.

Last edited on
1
2
3
4
5
6
7
...
    while (std::getchar())  // reads a character from std::cin
    {
        if (!std::getline( myfile, line)) break;  // tries to read a new  line to the string object
        std::cout << line;      // writes the string to standard output stream
    }
    ...

This works for getting a new line each time pressing <Enter>
Last edited on
Topic archived. No new replies allowed.