Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

String manipulation

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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. …
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

877 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