Solved

String manipulation

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 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