I have also copied the exact code from Programming Principles & Practice but to no avail.
I get an error message when I try to use std::sort(word) or sort(word):
<source>: In function 'int main()':
<source>:13:14: error: no matching function for call to 'sort(std::vector<std::__cxx11::basic_string<char> >&)'
   13 |     std::sort(words);
      |     ~~~~~~~~~^~~~~~~
[...]
The code:
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
    std::vector<std::string> words;
    for(std::string temp; std::cin >> temp;){
        words.push_back(temp);
    }
    std::cout << "Number of words: " << words.size() << "\n";
    std::sort(words);
     for(int i=0; i < words.size(); i++){
        if(i == 0; words[i-1]!=words[i]){
            std::cout << words[i] << "\n";
        }
    }
}
 
     
     
    