|
|
|
|
|
|
|
|
PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
std::this_thread::sleep_for(std::chrono::seconds(5)); // Requires header files "chrono" and "thread".
You need the header files mentioned and the only part to worry about is the number in (). This is the number of whole seconds that the program will pause before continuing. Some times you do not have to know everything just how to use it.int count{};
. The empty {}s will initialize the variable to zero. Then in the while loop add count++;
. After the while loop you can "cout" "count" to see how many words there are.
|
|
file >> word
part will read up to the first white space or new line character whichever comes first. Since the words in your input file are separated by a space and end with a new line this works well to read each word.
|
|