#I need to print a strcmp into alphabetical order when it outputs or say the name is the same.

10 messages · Page 1 of 1 (latest)

deft nymph
#

I cannot get the out put to be put in alphabetical order and im not sure what im doing wrong.
here is the problem they want
Write a program that reads two names (name1, name2)
And then prints them in alphabetical order.
If the names are the same, print a message indicating that the names are the same.

Hint: use the strcmp() function to compare the names.
strcmp() returns 0 if the strings are the same.
strcmp() returns a negative number if the first string is less than the second string.
strcmp() returns a positive number if the first string is greater than the second string.

Example:
Enter name 1: John
Enter name 2: John
John and John are the same.

Enter name 1: John
Enter name 2: Mary
John and Mary.

Enter name 1: Mary
Enter name 2: John
John and Mary.

floral ploverBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

alpine fulcrum
#

A better hint: use normal comparison operators.

deft nymph
#

not sure what that means

alpine fulcrum
#

string1 < string2.

deft nymph
#

took me way to long to get that. Thank you ill def do that next time

#

brain isnt working idk why i htought it needed to be nameOne and nameTwo instead of string1 and string2

#

Thank you!

#

!solved