How to read hex values from a file using fstream in c++? -


as title says, how read hex values using fstream?

i have code: (let's have "ff" in file.)

fstream infile; infile.open(filename, fstream::in|fstream::out|fstream::app);  int a; infile >> std::hex; infile >> a; cout << hex << a; 

but not give me output instead of ff. know there fscanf(fp, "%x", val) curious there way using stream library.

update:

my code right along, turns out error couldn't read "fff" , put in variable a,b,c this

while (infile >> hex >> >> b >> c)   {     cout << hex << << b << c << "\n";   } 

can me this? have separate every hex values want read space? because infile >> hex >> setw(1) doesn't work..

you can use hex modifier

int n; cin >> hex >> n; 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -