c++ - reading a hex column from input file -


heres sample of file: has 2 columns, second 1 hex value

0 298478 0 298478 2 3636 0 70f60874 ...

im trying put first column in vector , second column in vector, ive tried multiple things either stops after reaches 'f' in fourth line of input file or gives me weird values when accessing vectors.

using namespace std;  int main() { vector <int> label; vector <int> address;  ifstream ifile("data.txt");  if (!ifile.is_open()) {     cout << "error opening file\n"; }  while (!ifile.eof()) {      int a;     long long b;     ifile >> >> hex >> b;     if (ifile.fail())     {         break;     }     label.push_back(a);     address.push_back(b);  }  cout << label[3] << "\n"; cout << address[3];  } 

when run get: 0 1895172212

if run without "hex >> b" accurate results wont past 'f' in line 4. please im new , appreciate

1895172212 correct value (when converting 70f60874 decimal), in other words - printing value decimal, if want print hexadecimal value need use hex output well.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -