String Manipulations



Can anyone provide information for how to retrieve the actual character
string from a CString object?

I am using the following code but it only returns the address of the string
and not the literal characters of the string. I know it has to be something
simple that I am overlooking but I have copied samples from MS that are
supposed to work but give the same results

CString strSports("Hockey is Best!");

TCHAR sz[1024];

lstrcpy(sz, strSports);

cout << strSports ;

If I follow documentation provided by Microsoft which states:
// while this line will put the content of the string out:

cout << (LPCTSTR) strSports;

I still only receive the address of the CString object at the console.

Please help!


.



Relevant Pages

  • Re: String Manipulations
    ... > character string from a CString object? ... CString str; ... > string and not the literal characters of the string. ... > I still only receive the address of the CString object at the console. ...
    (microsoft.public.vc.language)
  • Re: CString GetBuffer() always needs ReleaseBuffer?
    ... How can copying the string be inexpensive? ... Isn't it true that a new CString object must be allocated, ... called, string memory allocated, string data copied, destructor called, ... > "Jonathan Wood" wrote in message ...
    (microsoft.public.vc.mfc)
  • Re: String Manipulations
    ... But I didn't explicitly designate my program to run under Unicode ... > CString str; ... >> string and not the literal characters of the string. ... >> I still only receive the address of the CString object at the console. ...
    (microsoft.public.vc.language)
  • Re: CString GetBuffer() always needs ReleaseBuffer?
    ... > Isn't it true that a new CString object must be allocated, ... > called, string memory allocated, string data copied, destructor called, ... The string data is not copied. ...
    (microsoft.public.vc.mfc)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)

Loading