hello,
Thanks to previous help which has gotten me this far.
However, my lovely program, although looks great in theory doesnt do what its supposed to do. When I type in 3 words, it doesnt put them in order as it should. Can someone point out to me where I am going wrong?
#include <iostream>
#include <string.h>
using namespace std;
int main ()
{
char word1[50] = "word1 string";
char word2[50] = "word2 string";
char word3[50] = "word3 string";
string wordsml;
string wordmed;
string wordlge;
cout<<"This program will ask you to enter 3 words. \n"
"It will then diplay them in order of word length \n"
"(Shortest word first)"<<endl;
cout<<"\tPlease enter 3 words\n";
cin>>word1>>word2>>word3;
if (strcmp (word1, word2)< 0)
{
wordsml = word1;
wordlge = word2;
}
if (strcmp (word1, word2)> 0)
{
wordsml =word2;
wordlge = word1;
}
if (strcmp(wordlge.c_str(), word3) <0);
{
wordmed = wordlge;
wordlge = word3;
}
if (strcmp(wordlge.c_str(), word3) >0);
wordmed = word3;
cout<<"The order of words from smallest to largest is "<<wordsml<<" and "<<wordmed<<" and "<<wordlge<<endl;
system("pause");
return 0;
}