我试图将表达式“5 + b * 18”转换为“5 + 16.89 * 18”。我的问题是在while循环中。我设法删除了空格。双C++中的字符串
我的代码:
double number = 16.89;
size_t found;
ostringstream converted;
string str ("5 + b * 18");
str.erase(remove(str.begin(),str.end(),' '),str.end());
found = str.find_first_of (VALID_CHARS);
while (found != string::npos)
{
converted << fixed << setprecision (8) << number;
str.insert(found, converted.str());
found = str.find_first_of (VALID_CHARS,found + 1);
}
谁能帮助我?
Ty
Ty dude!我修好了它。 – tiggares