Solved

RWCString to LPTSTR

Posted on 1998-10-07
6
557 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the real difference between C++ and Visual C++.NET? 7 120
c++ getting the first 10 characters of a char* string 11 99
c++ syntax question 9 52
learn programming 8 42
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

830 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