if(strcmp (Total_Names[i], Total_Names[i + 1]) != 0)
strcmp will return:
0 - if both strings are identical
less than 0 - if the "right" string comes first
greater than 0 - if the "left" string comes first
Since you are only checking to see if the value is !=0, you are only looking to see if the strings are identical or not. You are not seeing which one would come first.
I'm sorry I couldn't understand. I'm try to make sure that it start sorting/arranging names alphabetically.
if I understand of what you're saying is that I have to write two more of the if statements to check for greater or less than 0?
Also what if I turn the bool in the if statement to false and other true. would that help?
Last edited on
No. You just need two if() statements. One for strcmp() > 0 and one for strcmp() < 0.
If strcmp() == 0 you don't have to do anything.