RWCString to LPTSTR

Environment: Win NT 4, VC++ Version 5

How do I copy the contents of an RWCString into an
LPTSTR? Attempted the following:

RWCString prodCode;
LV_ITEM   description;

strcpy(description.pszText,prodCode.data());

(RWCString is from rogue wave)
jamessiddleAsked:
Who is Participating?
 
pauloserraCommented:
To make sure you have allocated the memory for the string, use:
description.pszText = strdup (prodCode.data();

0
 
slinkyCommented:
Try casting each side appropriately, sometimes you have to give the compiler some help.
0
 
nietodCommented:
What sort of problem are you having with that?

Does pszText point to a memory location that can store the string?  Is it long enough?
Does the data() member return a NUL terminated string?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
jamessiddleAuthor Commented:
More information: I am attempting to do as above, to assign the rogue wave string to a member of a structure (MFC) that is used in the InsertItem member of CListCtrl. I am attempting to add a subitem to an item in a CListCtrl, and using this structure seems to be necessary.

That said, perhaps this question would be better in the MFC forum?
0
 
danny_pavCommented:
what is the definition of RWCString?
also, if you are using LPTSTR you should use _tcs functions and not str functions
0
 
danny_pavCommented:
is RWCString a class? does it have an operator LPCTSTR()?

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.