Solved

MFC HexString to ASCII

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

758 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

22 Experts available now in Live!

Get 1:1 Help Now