Solved

char[] to LPSTR

Posted on 1998-03-14
1
1,909 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 92
Best tools for Backup and restore of Wordpress site 6 57
has22 challenge 11 94
Unix Command -- Challenging  question 7 90
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 …
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

772 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