I have a CString :
CString data;
data.Format = ("!64.8 Px.1= 1200");
I would like to copy the number 1200 from data to another CString data2.
Anyone can help?
Thanks in advance
I have a CString :
CString data;
data.Format = ("!64.8 Px.1= 1200");
I would like to copy the number 1200 from data to another CString data2.
Anyone can help?
Thanks in advance
CString::Format()
works like sprintf()
, so you can do ..
CString data;
CString data2 = _T("1200");
data.Format(_T("!64.8 Px.1= %s"), (LPCTSTR)data2);
CString::Format()
works likesprintf()
, so you can do ..CString data; CString data2 = _T("1200"); data.Format(_T("!64.8 Px.1= %s"), (LPCTSTR)data2);
For my application, the number 1200 from data string keep changing. I would like to copy the number out from data to another CString data2 so that i can prinf the number from data2 instead of the whole string of data.
data.Format(_T("!64.8 Px.1= 1200")); // 1200 keep changing
//Copy the number 1200 from data to data2
printf("%s", data2); //prinf the number instead of whole string
Is there a way to just copy the number from CString data to CString data2?
Thank you.
How about by-passing the CString here, and printf()
'ing the number directly, so,
// Somewhere you probably have ..
int the_number;
// .. and then output it ..
printf("!64.8 Px.1= %d", the_number);
If that's not an option, then you have to parse the data
string to get the number.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.