PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
|
|
if ((letter3 < letter1) && (letter3 < letter2))
. I did not see where "letter3" was ever given a value after it was defined, so you are comparing an empty string here and the other place it is used. I think in the second "cin" you meant to make the first variable "letter3", but you used "letter2" instead.
|
|
This is a Letter and Word sorting program Enter two different words separated by a space: b a Enter two different words separated by a space: bob alix "a" goes before "b" "alix" goes before "Defined, but empty" Press Enter to continue: |
This is a Letter and Word sorting program Enter two different words separated by a space: a b Enter two different words separated by a space: alix bob "Defined, but empty" goes before "Defined, but empty" "Defined, but empty" goes before "Defined, but empty" Press Enter to continue: |
if ((letter1 < letter2) && (letter1 < letter3))
and with a more proper variable name:if ((letter1 < letter2) && (letter1 < word1))
for the rhs of && you can easily see that you are comparing a string with a single letter to a string with several letters. The returned value of the "string compare" http://www.cplusplus.com/reference/string/string/compare/ may not bee what you want.
|
|
This is a Letter and Word sorting program Enter two different letters separated by a space: a b Enter two different words separated by a space: Andy Dave a goes before b Andy goes before Dave Press Enter to continue: |