Hello,
I'm learning C++ with VS 2017 using a text book called Programming: Principles and Practices Using C++ (second ed).
I'm beginning to think there is a conflict regarding the language used. The book focuses on C++11 and perhaps C++14 is what VS wants. Though I'm speculating.
The code below is taken straight out of the text book.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include "stdafx.h"
#include "std_lib_facilities.h"
int main()
{
vector<string>words;
for(string temp; cin >> temp;)
words.push_back(temp);
cout << "Number of words: " << words.size() << '\n';
sort(words);
for(int i = 0; i < words.size(); ++i)
if (i == 0 || words[i-1] != words[i])
cout << words[i] << '\n';
return 0; // I have a break point at this line.
}
| |
I'm suppose to be able to enter the following;
a man a plan a canal panama
Exactly as shown on the first line then press enter. It should then print to screen;
a
canal
man
panama
plan
The issue is that when I do this and hit enter, nothing happens. The cursor moves to the beginning of the next line, the first line has the string of text, nothing. No output.
What's missing?
Thanks.
Edit: Found an up-to-date version of std_lib_facilities.h. Removed redundant headers and change the "sort" to match the book exactly without errors. Problem still persists.