Help with word comparison

How can i write a program comparing the length of two words, and then say if the first word is greater, equal or lesser than the second ? thanks.

1
2
3
4
5
6
7
8
std::string word1, word2;
std::cin >> word1 >> word2;
if(word1.length() > word2.length())
    std::cout << word1 << " is longer than " << word2;
if(word1.length() < word2.length())
    std::cout << word1 << " is shorter than " << word2;
if(word1.length() == word2.length())
    std::cout << word1 << " same length as " << word2;
thank you very much!!
Topic archived. No new replies allowed.