Re: String Manipulations



Mark <mark_ivey4@xxxxxxxxx> wrote:
> Can anyone provide information for how to retrieve the actual
> character string from a CString object?

CString str;
LPCTSTR p = str;

> 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 ;

Why did you copy into sz buffer if you never use it?

> 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.

It appears that you are building a Unicode build. If so, use wcout
instead of cout.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • 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)
  • F is evil (was: XML::LibXML UTF-8 toString() -vs- nodeValue())
    ... And with C<use encoding 'utf8';> you'll get the same character string, ... A script is the complete program text, ...
    (comp.lang.perl.misc)
  • Re: Cell formatting issue
    ... the query process select Preserve cell formatting ... The character string should be ... than opening it intoExceland found the character string did ... Looking at the .xls file I do not see a difference ...
    (microsoft.public.excel.misc)
  • Re: Question about Descriptors
    ... > let you effortlessly do math with numbers that were stored in strings. ... If you moved a character string with numeric characters ... I think I missed the posting that defined string processing. ... String processing includes a native ability to define character string variables ...
    (comp.os.vms)
  • Re: Can somebody point me in the right direction?
    ... ten from the ten character string. ... There should be little probability of entering a random character string ... If you use encryption you have a potential problem at the second black ...
    (sci.crypt)