我一直都在這裏折磨我的大腦:字符串比較是怪異
cout << orig << " * " << count << endl;
string check = multiply2(orig, count);
cout << "Check was: " << check << " and number is: " << number << endl;
cout << "the compare result: " << check.compare(number) << endl;
if(check.compare(number) == 0)
{
cout << "wahoo it matches!!! we did it! " << endl;
}
else
{
cout << "Doesnt Match " << endl;
}
我期待它來搭配和打印wahoo it matches!!! we did it!
但與其說它不匹配。
這裏是我的輸出:
1 * 900000
Check was: 900000 and number is: 90000
the compare result: 1
Doesnt Match
任何人有任何想法,爲什麼他們arent匹配?
它們各自的類型是什麼?你是如何設置它們的? – 0x499602D2
嗯,一個數字有5個數字,另一個有6個數字.... –