?
Solved

MFC HexString to ASCII

Posted on 2008-06-12
2
Medium Priority
?
1,411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

777 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