Hi just wondering how i can convert ascii to binary then into hex then print it to the screen.

The user will input 5 chars then do the conversion and print

Recommended Answers

All 2 Replies

use atoi() to convert ascii to integer, then use sprintf with "%x" format argument to convert the integer to hex string.

If the goal is to display the hexadecimal equivalent of a char on the screen using C++ I/O and you don't want to do all the conversions yourself, then options to atoi() and sprintf() with "%x" format include converting the char to int with strol() and using the ios::hex flag respectively.

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.