string.compare知識糾正

A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows. First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). Then compare the sequences by calling Traits::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows:

當s1和s2作比較:(翻一下文檔的解釋)

先取s1,s2的較短長度作爲比較長度,然後按該長度進行比較,若出現ASCII碼的差,直接返回,若沒有出現差,再判斷二者的size,size1>size2,則返回>0.

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章