Solved

RWCString to LPTSTR

Posted on 1998-10-07
6
546 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
Comment Utility
Try casting each side appropriately, sometimes you have to give the compiler some help.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 3

Expert Comment

by:danny_pav
Comment Utility
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
Comment Utility
is RWCString a class? does it have an operator LPCTSTR()?

0
 
LVL 1

Accepted Solution

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

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

771 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

13 Experts available now in Live!

Get 1:1 Help Now