Write a C program to convert String into Hexadecimal

By | December 3, 2016

C program to convert String into Hexadecimal


Write a C program to convert String into Hexadecimal. This article shows you how to convert string into hexadecimal. Below is the code that is used to convert a string to hexadecimal format.


Hexadecimal


According To Wikipedia, 

In mathematics and computing, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a, b, c, d, e, f) to represent values ten to fifteen.

  • Hexadecimal numerals are widely used by computer system designers and programmers. One hexadecimal digit represents a nibble (4 bits), which is half of an octet or byte (8 bits).
  • For example, a single byte can have values ranging from 00000000 to 11111111 in binary form, but this may be more conveniently represented as 00 to FF in hexadecimal.
  • The prefix “0x” is used in C and related languages, where this value might be denoted as 0x2AF3.

In this program we will read a String and convert the string to Hexadecimal String. We will convert each character of the string in it’s equivalent hexadecimal value and insert the converted value in a string and finally print the Hexadecimal String.

Below is the source code of the C program to convert String to Hexadecimal which is successfully compiled and run on the windows system.The Output of the program is shown below.


SOURCE : :



Output : :


Leave a Reply