Solved

MFC HexString to ASCII

Posted on 2008-06-12
2
1,303 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now