I need to convert an ASCII string like... "hello2" into it's decimal and or hexadecimal representation (a numeric form, the specific kind is irrelevant). So, "hello" would be : 68 65 6c 6c 6f 32 in HEX. How do I do this in C++ without just using a giant if statement?
dansnyderECE
0
Junior Poster
Recommended Answers
Jump to PostThis is a really easy way to do it. Might be an easier/better way but this is what I put together in a few mins.
#include <iostream> #include <string> using namespace std; int main() { string sean = "hello2"; cout << sean << endl; for( unsigned int …
Jump to PostWhat exactly are you trying to solve? Why do you need its hex values? Are you hashing?
All 5 Replies
sfuo
111
Practically a Master Poster
dansnyderECE
0
Junior Poster
mrnutty
761
Senior Poster
sfuo
111
Practically a Master Poster
vijayan121
1,152
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.