[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

converting a LPSTR type into a char array

Posted on 2000-05-09
3
Medium Priority
?
1,002 Views
Last Modified: 2012-06-21
How do I convert a LPSTR value into a char array easily?

0
Comment
Question by:asaikovs
[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 5

Expert Comment

by:Wyn
ID: 2795623
Use LPSTR as is char array,why casting ?
0
 
LVL 2

Accepted Solution

by:
trillo earned 200 total points
ID: 2795692
Supose you have

LPSTR str;
this is the same as declaring
char *str;

To convert Use:
1) Copy the string
char ch[LEN];
strcpy(ch, str);

2) Use it directly...
LPSTR str;
You can access the characters in 'str' as if it was an array
str[0] = 'h';
str[1] = 'e';
str[2] = 'l';
str[3] = 'l';
str[4] = 'o';
str[5] = 0;   // Null character

1
 

Author Comment

by:asaikovs
ID: 2798023
Excellent!!!
Exactly what I was after
0

Featured Post

Technology Partners: 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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

656 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