|
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
Hi All
I am useing COleDateTime to get current time.Code is here
COleDateTime m_Date;
CTime time = CTime::GetCurrentTime();
CString cdate;
cdate=time.Format(_T("%d %b %Y"));
I have also one more CString oldetime="29 Jan 2009".Now i want to use "TimeSpan".How can i use time TimeSpan ?Plz help me
|
|
|
|
|
Use the operators that are overloaded in CTimeSpan class.
operator + – Adds and subtracts CTimeSpan objects.
operator += –= Adds and subtracts a CTimeSpan object to and from this CTimeSpan.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Thanks for reply.It's working.But CTimeSpan
CTimeSpan timeSpan = time- oldetime;
long day = timeSpan.GetDays();
How can i convert long day values in int or SCtring.Plz help me
|
|
|
|
|
See CString::Format function to convert long value in CString form.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
My code segment is as
TCHAR ProxyHost[20];
strcpy(ProxyHost, m_proxy_host_ip);
I am getting an error like
'strcpy' : cannot convert parameter 1 from 'TCHAR [20]' to 'char *'
How can I solve this? Plz help me.
Thanks
|
|
|
|
|
CString Management[^]
Read this article rather than posting your questions related to type conversions.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I have read that article. But not getting any help regarding this problem.
Can u please tell me the solution?
Thanks.
|
|
|
|
|
This article[^] is probably better to understand what's going on. After that, take a look at the documentation of sctrpy to check which is the unicode independant version of the function.
|
|
|
|
|
Purish Dwivedi wrote: I am getting an error like
'strcpy' : cannot convert parameter 1 from 'TCHAR [20]' to 'char *'
use _tcscpy instead
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
If it is
'strlen' : cannot convert parameter 1 from 'TCHAR [20]' to 'const char *'
then what to do?
|
|
|
|
|
Do you need _tcslen?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
There is a boatload of CRT string manipulation functions. You can be kind enough not to add a query here for every single function that is referred to in your code.
Just get to the documentation page[^] and click on the function that you're using. Then, choose the generic text mapping routine version (tchar.h routine) of that function. As an example, choose _tcsdec instead of _strdec . You might want to read about Using Generic Text-Mappings[^].
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Code Segment is
token=strtok(userid,_T(";"));
What about this error?
'strtok' : cannot convert parameter 2 from 'const wchar_t [2]' to 'const char *'
|
|
|
|
|
Is it really that difficult? Read my previous reply to you again. Go to the documentation page and click on strtok and choose the generic text mapping routine equivalent instead.
You need to read on Unicode, Generic Text mappings, Internationalization, and string manipulation. You really need to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have changed that.
Now the new error is
'wcstok' : cannot convert parameter 1 from 'char [1000]' to 'wchar_t *'
what should I do now?
|
|
|
|
|
Purish Dwivedi wrote: what should I do now?
You are looking for someone to give you an 'instant fix' (not to mention you post a query for every error of the same type) without even understanding your problem properly, which is essentially not going to help you in the longer run. I am wanting you to understand the basics so that you will be able to solve the problem yourself.
Therefore, do what Cédric asked you to do[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I'm not getting that what to do?
Plz help me.
thanks.
|
|
|
|
|
Purish Dwivedi wrote: I'm not getting that what to do?
Look, people here are willing to help but if you don't want to put any effort yourself, then you can forget about it. The article I linked to you contains a lot of information about unicode and non-unicode builds. Once you have read the article, you will understand that to support both unicode and non-unicode builds, you will need to use TCHAR (and not char) and all the unicode-independant string manipulation routines (instead of strcpy, strlen, strtok, ...). For ALL of those functions, if you look in the MSDN documentation, you have a table that compares the different versions. You always have to use the "TCHAR.h routine" version.
|
|
|
|
|
Cedric Moonen wrote: unicode-independant string manipulation routines
Would that be rather character set independent string manipulation routines? OK, I'm just being a nitpick.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: Would that be rather character set independent string manipulation routines?
To be honnest, I didn't know the exact terminology. Now I know
|
|
|
|
|
As someone else mentioned, it looks like you have some mixed UNICODE and ANSI problems.
Ti make the code portable, make sure you have included "TCHAR.H" and use
_tcslen instead of strlen.
That should fix the problem.
Tony
|
|
|
|
|
try _tcscpy_s function instead strcpy function
take a look in strpy definition strcpy work only ASCII , but TCHAR is char if Unicode is not defined or TCHAR is wchar_t if Unicode is defined
|
|
|
|