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