Solved

MFC HexString to ASCII

Posted on 2008-06-12
2
1,317 Views
Last Modified: 2013-12-14
In Visual C++ 6.0, I need to convert a CString hex variable with a value such as "FF" to an ASCII char that represents that string as a hex value.
0
Comment
Question by:psft
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 21773981
No problem:
#include <stdlib.h>
CString str = "FF";
char* pEnd;
 
long l = strtol((LPCTSTR)str,&pEnd,16);
 
char c = (char) l; // now you have a char that is set to 0xFF

Open in new window

0
 
LVL 1

Author Closing Comment

by:psft
ID: 31466752
Hey thanks!  
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
The line on IDE 4 84
Header Errors LNK2019, LNK1120 - Unresolved Externals 4 131
Not needed 13 110
Embarcadero WebBroker REST server endpoint parameters 2 64
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question