Check if one string is a prefix of another
问题 I have two strings which I'd like to compare: String and String: . Is there a library function that would return true when passed these two strings, but false for say String and OtherString ? To be precise, I want to know whether one string is a prefix of another. 回答1: Use std::mismatch. Pass in the shorter string as the first iterator range and the longer as the second iterator range. The return is a pair of iterators, the first is the iterator in the first range and the second, in the