忽略c ++间距的最有效方法?

时间:2018-05-03 01:19:13

标签: c++ string string-comparison

如果我有两个字符串:

string str1 = "Something about the way that you walked into my living room";

string str2 = "Something about    the way that   you        walked into my  living room";

如何编写函数来返回这两个字符串是一回事?

1 个答案:

答案 0 :(得分:3)

首先,您可以使用此处给出的单个空格替换多个连续的空格

Replace multiple spaces with one space in a string

然后比较字符串