c++ - How to cast from hex to int and char? -


is there way convert/cast hex decimal , form hex char? example if have:

string hexfile = string(argv[1]); ifstream ifile; if(ifile)   ifile.open(hexfile, ios::binary); int = ifile.get();  // getting hex form hexfile , want  char c = ifile.get(); // convert decimal representation int , char 

thank you.

std::string s="1f"; int x;    std::stringstream ss; ss << std::hex << s; ss >> x;  std::cout<<x<<std::endl; //this base 10 value std::cout<<static_cast<char> (x)<<std::endl; //this ascii equivalent 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -