瀏覽單個文章
疾如風
New Member
 
疾如風的大頭照
 

加入日期: Aug 2006
文章: 9
把16進位string轉成int偷懶的作法,用std::stringstream

代碼:
#include <sstream>
#include <iostream>

using namespace std;

int main() {
    int a;
    stringstream ss;
    string str = "FF";

    ss << hex << str;
    ss >> a;
    cout << hex << a+1 << " " << a-1 << endl;

    return 0;
}
 
舊 2011-12-16, 11:53 AM #2
回應時引用此文章
疾如風離線中