Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

LPSTR/CString

Posted on 2000-04-11
3
Medium Priority
?
1,443 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

972 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