|
If unicode is not enabled this is done automatically (CString has a LPCTSTR). If UNICODE is enabled, then you should perhaps revise what you are doing and use TCHAR instead of char*. For which exact reason do you want the conversion ?
|
|
|
|
|
actually I want to getvalue from editcontrol in char* format
also set the value from char* to the editcontrol.
Trioum
|
|
|
|
|
Why a char pointer ? If you are using functions like SetWindowText and GetWindowText, they accept a LPCTSTR too. I really suggest that you take a look at this article[^]. It's a bit of reading but after it you'll definitevly know what you are doing and you will avoid any future problem. So, definitively a must read .
|
|
|
|
|
Well I was just going to point him to that article. 5 for beating me to it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I don't know why, but an idiot is down voting every good posts in this thread.
come to my help bro
|
|
|
|
|
Done.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Some sh*t-head down-voted almost all the messages on my profile page. Not a very good thing, I'd say.
|
|
|
|
|
let me check that
[edit] where ? I can't really found 1 votes on your profile... [/edit]
|
|
|
|
|
Well the above is not completely correct: since, as you pointed out, CString has the LPCTSTR operator, (when _UNICODE is not defined) you may cast it to a const char * pointer. If the OP really needs a char * then he has to do more (not excluding the Mark's favourite, (in)famous, CString::GetBuffer )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Yes, you're right about the constness, Alfonso the Wise
|
|
|
|
|
You're a bad guy!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Click here for more conversion[^]
CString orig("Hello, World!");
wcout << orig << " (CString)" << endl;
const size_t newsize = 100;
char nstring[newsize];
strcpy(nstring, orig);
strcat(nstring, " (char *)");
cout << nstring << endl;
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Please Give me the reason of downvoting.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
I am not the one downvoted,
strcpy(nstring, orig /* CString object*/); // think.
it is not generic solution although your code is not unicode build,
CString orig("Hello, World!");
|
|
|
|
|
Thanks for reply Rajkumar but i give answer according to question
How to convert CString to char* in vc++ 6 platform
Trioum is not specific. May be his code is not unicode build.
It is not the wrong answer.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
you should had a comment regarding this in your orginal post, and also i think you added the link to msdn regarding string conversion after you got downvoted.
modified on Friday, May 23, 2008 3:38 AM
|
|
|
|
|
No you are totally wrong.i edit link because in that code
strcpy_s and strcat_s is used and in vc 6.0 these function is not working.
please check the link.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
ok, corrected.
|
|
|
|
|
gr8.. u r intelligent ...
Don`t fight .......
Where did u find this quote---
"Yes U Can ...If U Can ,Dream it , U can do it ...ICAN"
..
|
|
|
|
|
Dont Fight
When i was doing MCA, One of the guest faculty give a seminar about PD and i was impressed and also like his line
Yes you can,
If you can dream it,
You can do it.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
gr8..
I am also impressed....
Well.. where r u working...????
how much experience u have...??
|
|
|
|
|
do you have a problem with your keyboard ?
or with your english maybe ?
|
|
|
|
|
wht happened.........
|
|
|
|
|
Ashutosh Shashi wrote: wht happened
wht NO ! --> what
Ashutosh Shashi wrote: gr8..
I am also impressed....
Well.. where r u working...????
how much experience u have...??
gr8 NO !! --> great
r hell NO !!! --> are
u f*ck NO !!!! --> you
man, this is not a mobile phone. SMS is not the proper way to express yourself here.
also, why did you vote the whole thread '1' ?
|
|
|
|
|
thankx ........
u r looking so intelligent..
|
|
|
|