Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LPSTR/CString

Posted on 2000-04-11
3
Medium Priority
?
1,425 Views
Last Modified: 2013-11-20
How do I convert a CString to a LPSTR?
CString ctmp = "Hello";
LPSTR tmp = ctmp;
The above will not compile.
0
Comment
Question by:hotwheels
[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
3 Comments
 
LVL 1

Expert Comment

by:MT_MU
ID: 2704741
CString ctmp = "Hello";
LPSTR tmp = (char *)(const char*)ctmp;
0
 
LVL 4

Accepted Solution

by:
inpras earned 150 total points
ID: 2704804
Hi
      CString str;
      str = "My String";
      LPSTR str1;
      strcpy(str1, str);

Hope this helps
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2704899
LPCTSTR is the "const char *"
LPSTR is the "char *"
fro ANSI builds
they are both fully interchangable
if you are not going to change the context (or going to if you want)

so no need to strcpy( ) it

just do casting

CString str = "string";
LPSTR lpstr = (LPSTR)(LPCTSTR)str;

will get the pointer to Cstring's buffer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

715 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