/////////////////////////////////////////////////////////////// // MT4Q1b - Convert to and from Hexadecimal the hard way // // // // Jim Fawcett, CSE687 - OOD Midterm, Spring 2013 // /////////////////////////////////////////////////////////////// #include #include #include "../MTutility/MTutility.h" std::string HexToString(int i) { std::string temp; do { char a = i%16 + '0'; if(!isdigit(a)) a += ('a' - '0' - 10); //////////////////////////////////////////////////////////// //The lines below are equivalent to the previous line. //switch(a) // convert chars after '9' in ASCII to alphas //{ //case ':' : a = 'a'; break; //case ';' : a = 'b'; break; //case '<' : a = 'c'; break; //case '=' : a = 'd'; break; //case '>' : a = 'e'; break; //case '?' : a = 'f'; break; //} temp += a; i /= 16; } while(i != 0); std::string out; for(size_t i=0; i