Solved

RWCString to LPTSTR

Posted on 1998-10-07
6
560 Views
Last Modified: 2007-10-18
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)
0
Comment
Question by:jamessiddle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:slinky
ID: 1174615
Try casting each side appropriately, sometimes you have to give the compiler some help.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1174616
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
 

Author Comment

by:jamessiddle
ID: 1174617
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:danny_pav
ID: 1174618
what is the definition of RWCString?
also, if you are using LPTSTR you should use _tcs functions and not str functions
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1174619
is RWCString a class? does it have an operator LPCTSTR()?

0
 
LVL 1

Accepted Solution

by:
pauloserra earned 50 total points
ID: 1174620
To make sure you have allocated the memory for the string, use:
description.pszText = strdup (prodCode.data();

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question