All pastes #910342 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-19 21:49 UTC
rendered paste body
#include <iostream>
#include <sstream>
using namespace std;

int main (int argc, char * const argv[]) {
	char szHexInput [9];
	stringstream ssHexInputFixed, ssByteBuffer, ssFinalHex;
	
    cout << "Please enter hex to be converted: 0x";
	cin >> szHexInput;
	
	int nLength = strlen(szHexInput);
	
	for(int i = 0; i < (nLength + 1); i++)
	{
		ssByteBuffer << szHexInput[nLength - i] << szHexInput[nLength - (i - 1)];
		ssFinalHex << ssByteBuffer.str().c_str();
		ssByteBuffer.str("");
		
	}	
	
	
	cout << "Final Hex: " << ssFinalHex.str().c_str() << endl;
	
    return 0;
}