Advertisement
AntonioVillanueva

Conversor INT to HEX C++

Aug 26th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4.  
  5. //using namespace std;
  6. std::string hexa(int h) {
  7.     int i=0;
  8.     std::stringstream s;
  9.     s<< std::hex << h; 
  10.     std::string o( s.str() );
  11.      while (o[i]){
  12.         o[i]>='a' ? o[i]-=' ':
  13.         i++;}      
  14. return o;
  15.  
  16. }
  17. int main (){
  18.     std::cout<<hexa(12)<<std::endl;
  19.     std::cout<<hexa(29)<<std::endl;
  20.     return 0;
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement