Solved

RWCString to LPTSTR

Posted on 1998-10-07
6
548 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now