[問題] 數字的問題(以解決)
我寫了小程式,要讀檔把抓到的數字做運算
#include <iostream>
#include <conio.h>
#include <fstream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <sstream>
using namespace std;
int main(){
int value;
string token;
string s1;
fstream file("sic.txt",ios::in);
getline(file,s1);
istringstream fin( s1 );
fin >> token;
fin >> token;
fin >> token;
stringstream sin(token);
sin >> value;
cout<<hex<<value;
system("pause");
}
sic.txt裡是 first copy 1000
問題在 value此時是1000 十進位的整數
可是我要的1000是16進位
因為我要做16進位運算
例如+13 => 輸出100D
請問大大們要怎嚜改
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.10.155
推
06/07 17:09, , 1F
06/07 17:09, 1F
→
06/07 18:15, , 2F
06/07 18:15, 2F
→
06/07 19:57, , 3F
06/07 19:57, 3F
推
06/07 20:02, , 4F
06/07 20:02, 4F
推
06/07 21:06, , 5F
06/07 21:06, 5F
→
06/08 01:19, , 6F
06/08 01:19, 6F
推
06/08 05:02, , 7F
06/08 05:02, 7F
→
06/08 05:02, , 8F
06/08 05:02, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章