C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String Operation for numeric data

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
novice
Guest





PostPosted: Sun Mar 07, 2004 5:16 pm    Post subject: String Operation for numeric data Reply with quote



How can I do string operation for numeric data?

For example I'd like to cut the numeric data.
long nDate = 20040307; //Year = 2004, Month = 03, Day = 07
CString strDate, strYear, strMonth, strDay;

strDate.Format("%d", nDate);
strYear = strDate.Left(4);
strMonth = strDate.Mid(4,2);
strDay = strDate.Right(2);

In above example, I can cut the numeric data as string.
But how can I use the value of CString as numeric data?
I'd like to pass the each value to CTime variable like this.
CTime tTime (strYear, strMonth, strDay, nTime, nMinute, nSecond);
-------- -------- ------
Error! Error! Error!

(int)(LPCTSTR)strYear doesn't work either.

Any comments would be greatly appreciated.

john
Back to top
Jon Bell
Guest





PostPosted: Sun Mar 07, 2004 6:30 pm    Post subject: Re: String Operation for numeric data Reply with quote



In article <3a63ccda.0403070916.15584cbf (AT) posting (DOT) google.com>,
novice <bjh1004 (AT) hotmail (DOT) com> wrote:
Quote:

In above example, I can cut the numeric data as string.
But how can I use the value of CString as numeric data?

CStrings are a Microsoft invention, not part of standard C++. Therefore,
you had best ask about them in a Microsoft-specific newsgroup, e.g. one of
the comp.os.ms-windows.programmer.* or microsoft.public.vc.* groups.

--
Jon Bell <jtbellm4h (AT) presby (DOT) edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.