How to display hex string as characters in C++

1 Answer

0 votes
#include <iostream>
#include <sstream>

int main(void)
{
    std::string s = "432b2b2050726f6772616d6d696e67";
      
    size_t len = s.length();

    for(size_t i = 0; i < len; i += 2) {
        unsigned int n;   
        std::stringstream ss;
        ss << std::hex << s.substr(i, 2);
        ss >> n;
         
        std::cout << char(n);
    }

    return 0;
}
  
  
  
  
  
/*
run:
  
C++ Programming
 
*/

 



answered Sep 19, 2021 by avibootz

Related questions

1 answer 155 views
1 answer 240 views
2 answers 431 views
431 views asked Dec 29, 2021 by avibootz
1 answer 218 views
2 answers 169 views
169 views asked Sep 18, 2021 by avibootz
1 answer 159 views
2 answers 187 views
187 views asked Dec 29, 2021 by avibootz
...