Solved

char[] to LPSTR

Posted on 1998-03-14
1
1,923 Views
Last Modified: 2013-11-19
I need to convert from char[] to LPSTR.  Is it tecnically correct to do this way:

char Source[25] = {"\0"}; //is this the correct way to initialise it?

strcpy(Source, "TEST") ;

TV_INSERTSTRUCT TreeCtrlItem;
TreeCtrlItem.item.pszText = (LPSTR)Source;
      
0
Comment
Question by:leowlf
[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
1 Comment
 
LVL 3

Accepted Solution

by:
stefanr earned 20 total points
ID: 1316987
The conversion is perfectly legal (in fact it is the same), but I do believe that the correct way to initialize the array is
char Source[25] = { 0 };

"\0" is a pointer that is != zero. Therefore I believe the initialization would not be as you expected.

/Stefan
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 36
zeroMAx challenge 20 134
scoreUp challenge 14 73
mapBully challenge 6 196
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

738 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