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:
...
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>