RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++

Convert Hex String to an Integer Value.

Author: Embarcadero USA

 Technical Information Database

TI2203C.txt   Convert Hex String to an Integer Value.
Category   :General
Platform    :All
Product    :C/C++  All

Description:
This document provides a method to read hexadecimal numbers.
The atoi() function ignores the A-F digits in a hexadecimal
number.  In fact, the first non-digit character in the string
passed to atoi() ends the conversion.
The following example converts a four-character text string that
represents a hexadecimal number into an integer.  It can be used
as a template to create other ASCII-to-number conversions.
The example code defines a C\C++ function called axtoi() that
does the conversion.  It includes a short main() that to test the
function.
#include 
int axtoi(char *hexStg) {
  int n = 0;         // position in string
  int m = 0;         // position in digit[] to shift
  int count;         // loop index
  int intValue = 0;  // integer value of hex string
  int digit[5];      // hold values to convert
  while (n  0x29 && hexStg[n] ='a' && hexStg[n] ='A' && hexStg[n] <<<<'s Evaluate|Modify. dialog you can and see how the ANDs,
ORs, and shifts work to find the value of each character in the
string.
CAVEATS
=======
N/A
BIBLIOGRAPHY
============
N/A


Reference:


7/2/98 10:40:41 AM
 

Article originally contributed by


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
News

Using C++17 Algorithms Library Parallel Sorting with C++Builder 10.4 Sydney for Win32 and Win64

C++News

C++Builder and Platforms Support

C++

What's New in the GetIt Package Manager - June 2020

C++

RAD Studio 10.4 Now Available, Learn More

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES