No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
This is my function that is supposed to take a base ten number and return the same number in a base 16(hexidecimal) format ie. 45 returns 2D instead I am getting 6850 [CODE] string inttohex (int n) { ostringstream buffer; string result; int num; num=n%16; if(num<10) buffer<<(num+'0'); else {buffer<< ((num-10)+'A');} … | |
[CODE]#include <iostream> #include <fstream> #include <sstream> #include <cstdlib> #include <string> using namespace std; int dectoint (string st); int hextoint (string st); int bintoint (string st); string inttobin (int n); string inttohex (int n); int main() { string st; cout<< "Enter a number in dec,hex,or binary: \n"; getline(cin,st); if (st[0]=='$') cout … | |
[CODE]#include <iostream> #include <fstream> #include <sstream> #include <cstdlib> using namespace std; int dectoint (string st); int hextoint (string st); int bintoint (string st); string inttobin (int n); //string inttohex (int n); //string inttodec (int n); int main() { string st; cout<< "Enter a number in dec,hex,or binary: \n"; getline(cin,st); if … |