Is string::compare reliable to determine alphabetical order?

前端 未结 5 1723
太阳男子
太阳男子 2021-02-14 06:59

Simply put, if the input is always in the same case (here, lower case), and if the characters are always ASCII, can one use string::compare to determine reliably the alphabetica

5条回答
  •  半阙折子戏
    2021-02-14 07:28

    Yes, as long as all of the characters in both strings are of the same case, and as long as both strings consist only of letters, this will work.

    compare is a member function, though, so you would call it like so:

    stringA.compare(stringB);
    

提交回复
热议问题