Solved

String manipulation

Posted on 1998-08-06
2
193 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

896 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now