Solved

String manipulation

Posted on 1998-08-06
2
206 Views
Last Modified: 2010-04-02
i save a 4 bytes unsigned char in a LPSTR variable like this  LPSTR lp="09080706" and i try to cut the first byte
and second byte of this variable but my program crasched when try to access this variable whats wrong.
0
Comment
Question by:saidi
[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
  • 2
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1169542
Post your code.  You are not trying to dereference the pointer are you.  That would definitly cause a crash.
0
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1169543
You could do
LPSTR StrPtr;

  ((char *) &StrPtr)[0] = "A";
  ((char *) &StrPtr)[1] = "B";
  ((char *) &StrPtr)[3] = "C";
  ((char *) &StrPtr)[4] = "D";

char Chr =   ((char *) &StrPtr)[1];  // get B.




0

Featured Post

Independent Software Vendors: 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

617 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