可能重复:
如何去掉字符串末尾的空格,使其变为:
请注意,这只是一个示例,不代表我的代码。我不想硬编码:
最佳的 std::string 剪裁方法是什么?
What's the best way to trim std::string
我有一个字符串:
std::string foo = "This is a string "; // 4 spaces at end
如何去掉字符串末尾的空格,使其变为:
"This is a string" // no spaces at end
请注意,这只是一个示例,不代表我的代码。我不想硬编码:
std::string foo = "This is a string"; //wrong