Inputing and Outputing Hexdecimal Integers with iostream

It is straightforward. I just put the example code:

#include <fstream>
#include <iomanip>

using std::cout;
using std::ifstream;
using std::ios;
using std::hex;

int main(){
    ifstream is("e:testtest.txt");
    int i = 0;
    is >> hex >> i;
    cout << hex << i << endl;
    is.close();
    return 0;
}

Eric Zhiqiang Ma

Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *