Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String manipulation

Posted on 1998-08-06
2
Medium Priority
?
209 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 400 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

670 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