Programming with Passion

Make the best out of everything.

Showing posts with label PROGRAM TO CONVERT HEX TO ASCII STRING. Show all posts
Showing posts with label PROGRAM TO CONVERT HEX TO ASCII STRING. Show all posts

Saturday, 19 March 2016

WRITE A C++ PROGRAM TO CONVERT HEX TO ASCII STRING

WRITE A C++ PROGRAM TO CONVERT HEX TO ASCII STRING






#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;


int main () 
{

 string Str;
  cout << "Enter A Hex Value eg.(0x4D) To Conver Into ASCII Char=" ;
   cin>>Str;
   cout << endl;
 std::istringstream iss (Str);
iss.flags(std::ios::hex);
int i;
iss >> i;

std::cout <<"OUTPUT=" << (char)i  << std::endl; 
  
  return 0;
}


OUTPUT:
Enter A Hex Value (0x4D) To Conver Into Hex=0x6D
OUTPUT=m