954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Extract Data out from CString type

I want the extract the two values(113.654321 and 114.654321) from the CString

CString sValue = "113.123456 114.654321";

I tried to use the TrimLeft function of the CString Class, which is
sNewValue1=svalue.TrimLeft(_T(" ")) and
sNewValue2=sValue.TrimRight(_T(" "))
but I cannot get the expected value. Can anyone help?

Thanks in advance!

LemonLemon
Newbie Poster
7 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
adnan.siddique
Light Poster
33 posts since Jan 2010
Reputation Points: 4
Solved Threads: 2
 

convert your cstring into char array and then use sscanf

string str = "asdfgh";
char * st = (char*)str.c_str();
adnan.siddique
Light Poster
33 posts since Jan 2010
Reputation Points: 4
Solved Threads: 2
 

If it is CString as in MFC, then CString has methods like, Find(), FindOneOf(), Left(), Right() and Mid().

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You