Click here to Skip to main content
16,011,988 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: strlen and char* Pin
jmkhael1-Oct-02 5:30
jmkhael1-Oct-02 5:30 
GeneralRe: strlen and char* Pin
User 66581-Oct-02 5:38
User 66581-Oct-02 5:38 
GeneralRe: strlen and char* Pin
jmkhael1-Oct-02 5:42
jmkhael1-Oct-02 5:42 
GeneralRe: strlen and char* Pin
Daniel Turini1-Oct-02 6:00
Daniel Turini1-Oct-02 6:00 
Generalstrcpy and CString question Pin
ns1-Oct-02 4:34
ns1-Oct-02 4:34 
GeneralRe: strcpy and CString question Pin
Nish Nishant1-Oct-02 4:46
sitebuilderNish Nishant1-Oct-02 4:46 
GeneralRe: strcpy and CString question Pin
ns1-Oct-02 4:52
ns1-Oct-02 4:52 
GeneralRe: strcpy and CString question Pin
Michael Dunn1-Oct-02 5:17
sitebuilderMichael Dunn1-Oct-02 5:17 
Nishant S wrote:
(LPTSTR)s

NO NO NO. Sorry, I get upset when I see people do that. That is totally wrong and a bad habit to get newbie programmers into.

First off, the second strcpy() argument is a const char* (I'm avoiding the TCHAR typenames because ns obviously doesn't know them). There is no cast needed because CString has a const char* conversion operator that is called implicitly.
Second, casting a CString to a char* breaks the CString interface -- you are using your knowledge of how a CString works internally, which you must not do to maintain OO encapsulation. The correct way to get a non-const pointer is GetBuffer().

--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm

GeneralRe: strcpy and CString question Pin
Jon Hulatt1-Oct-02 5:30
Jon Hulatt1-Oct-02 5:30 
GeneralRe: strcpy and CString question Pin
Jon Hulatt1-Oct-02 5:35
Jon Hulatt1-Oct-02 5:35 
GeneralRe: strcpy and CString question Pin
Nitron1-Oct-02 5:31
Nitron1-Oct-02 5:31 
GeneralRe: strcpy and CString question Pin
Nish Nishant1-Oct-02 5:38
sitebuilderNish Nishant1-Oct-02 5:38 
GeneralRe: strcpy and CString question Pin
JT Anderson1-Oct-02 5:41
JT Anderson1-Oct-02 5:41 
GeneralRe: strcpy and CString question Pin
Nish Nishant1-Oct-02 5:54
sitebuilderNish Nishant1-Oct-02 5:54 
GeneralRe: strcpy and CString question Pin
Michael Dunn1-Oct-02 7:48
sitebuilderMichael Dunn1-Oct-02 7:48 
GeneralRe: strcpy and CString question Pin
Rene De La Garza1-Oct-02 10:39
Rene De La Garza1-Oct-02 10:39 
GeneralRe: strcpy and CString question Pin
Michael Dunn1-Oct-02 14:07
sitebuilderMichael Dunn1-Oct-02 14:07 
GeneralRe: strcpy and CString question Pin
Rene De La Garza1-Oct-02 16:27
Rene De La Garza1-Oct-02 16:27 
GeneralRe: strcpy and CString question Pin
Ravi Bhavnani1-Oct-02 5:27
professionalRavi Bhavnani1-Oct-02 5:27 
GeneralRe: strcpy and CString question Pin
Jon Hulatt1-Oct-02 5:34
Jon Hulatt1-Oct-02 5:34 
GeneralRe: strcpy and CString question Pin
Ravi Bhavnani1-Oct-02 6:54
professionalRavi Bhavnani1-Oct-02 6:54 
GeneralRe: strcpy and CString question Pin
Michael Dunn1-Oct-02 7:50
sitebuilderMichael Dunn1-Oct-02 7:50 
GeneralDocument/View startup problem Pin
will13831-Oct-02 4:32
will13831-Oct-02 4:32 
GeneralRe: Document/View startup problem Pin
Tomasz Sowinski1-Oct-02 5:58
Tomasz Sowinski1-Oct-02 5:58 
GeneralRe: Document/View startup problem Pin
will13831-Oct-02 6:46
will13831-Oct-02 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.