这是我的问题:
std::string str = "12 13 14 15 16.2"; // my input
我想要
unsigned char myChar [4]; // where myChar[0]=12 .. myChar[0]=13 ... etc...
我尝试使用 istringstream:
std::istringstream is (str);
unsigned char myChar[4];
is >> myChar[0] // here something like itoa is needed
>> myChar[1] // does stringstream offers some mechanism
//(e.g.: from char 12 to int 12) ?
>> myChar[2]
>> myChar[3]
但我得到了(显然)
myChar[0]=1 ..myChar[1]=2 ..myChar[2]=3
没办法...我必须使用 sprintf 吗??!不幸的是,我不能使用 boost 或 C++11 ...
TIA