在 C++ 上忽略间距的最有效方法?

Most efficient way of ignoring spacing on c++?

如果我有两个字符串:

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";

我如何编写函数 return 这两个字符串是相同的东西?

首先,您可以将多个连续的 space 替换为此处给出的单个 space

Replace multiple spaces with one space in a string

然后比较字符串