请帮助消息框不接受参数

Please help message box doesnt accept parameter

本文关键字:不接受 参数 消息 帮助      更新时间:2023-10-16

我有这个函数,但它不起作用:

std::string s(Buffer);
std::string::size_type k = 0;
while ((k = s.find('"', k)) != s.npos) {
    s.erase(k, 1);
}
while ((k = s.find(' ', k)) != s.npos) {
    s.erase(k, 1);
}
::MessageBoxA(NULL, s.c_str, "Print recevied buffer", MB_ICONINFORMATION);

我有一个缓冲区(这是一个互联网页面),我想解析它以删除所有空格和字符"。我尝试了很多解决方案,但没有一个有效。
这个说我应该创建一个对字符串的引用,但我不明白这意味着什么。

你写了s.c_str(命名函数指针)而不是s.c_str()(实际调用函数)。

您的实际问题涉及使用k而不重置它。

while ((k = s.find('"', k)) != s.npos) {
    s.erase(k, 1);
}
k = 0; //you need to reset k in order to properly remove spaces
while ((k = s.find(' ', 0)) != s.npos) {
    s.erase(k, 1);
}