Solved

LPSTR/CString

Posted on 2000-04-11
3
1,403 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
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 50 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

11 Experts available now in Live!

Get 1:1 Help Now