64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
using namespace std;
int
main(int argc, char *argv[])
{
string s;
string r;
string::size_type b, e;
char c;
unsigned u;
char buf[1024];
s = "02000000,0000,0000a300,";
c = ',';
b = 0;
while (e != string::npos && b < s.length()) {
e = s.find(c, b);
if (e != string::npos) {
u = strtoul(s.substr(b, e).c_str(), NULL, 16);
b = e + 1;
} else {
u = strtoul(s.substr(b).c_str(), NULL, 16);
}
sprintf(buf, "%u", u);
r += buf;
r += c;
}
cout << r << endl;
return 0;
}