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 237 views
1 answer 324 views
2 answers 551 views
551 views asked Dec 29, 2021 by avibootz
1 answer 305 views
2 answers 269 views
269 views asked Sep 18, 2021 by avibootz
1 answer 245 views
2 answers 305 views
305 views asked Dec 29, 2021 by avibootz
...