0
当程序运行时,它在很长的时间内崩溃thislong = atoll(c);这有什么理由吗?当试图将const char *转换为long long时,程序崩溃
string ConvertToBaseTen(long long base4) {
stringstream s;
s << base4;
string tempBase4;
s >> tempBase4;
s.clear();
string tempBase10;
long long total = 0;
for (signed int x = 0; x < tempBase4.length(); x++) {
const char* c = (const char*)tempBase4[x];
long long thisLong = atoll(c);
total += (pow(thisLong, x));
}
s << total;
s >> tempBase10;
return tempBase10;
}
正确的缩进将是巨大的 – jogojapan 2013-02-14 05:49:32
' tempBase4 [x]'返回'char'不是'const char *' – billz 2013-02-14 05:49:40
'atoll'没有错误检查,为什么你会用你的方式在'char'上使用它? – chris 2013-02-14 05:50:32