Hello,
I am one of those new assignment people, BUT I have tried to resolve this for a while now. Cant find much on google or other C++ sites.
I am trying to compare string lengths of 3 words and then display them in order of length.
My code is (I get stuck just before my first if statement):
#include <iostream>
#include <string.h>
using namespace std;
int main ()
{
int x,y,z;
string word1 = "word1 string";
string word2 = "word2 string";
string word3 = "word3 string";
cout<<"Please enter 3 words/n";
cin>>word1>>word2>>word3;
x = strcmp(word1, word2); ***THIS LINE IS THE PROBLEM***
{
if (strcmp (word1, word2)< 0)
wordA = word1
wordB = word2
}
if (strcmp (word1, word2) > 0)
{
wordA =word2
wordB =word1
}
y = strcmp (wordA, word3)
if (y < 0)
wordsml = wordA
z = strcmp (wordB, word3)
if (z < 0)
wordm = wordB
if (z > 0)
wordlge = word3
cout<<"The order of words from smallest to largest is "<<word sml<<" and "<<wordm<<" and "<<wordlge<,endl;
system("pause");
return 0
}
I know I have done something wrong in my setout, but the explanation given to me is not very clear to me and I dont know how to resolve : ******no matching function for call to 'strcmp(std::string&, std::string&)' ****** Can someone head me in the right direction?
Thanks!