Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

structure conersion to char*

Status
Not open for further replies.

Wings

Programmer
Feb 14, 2002
247
US
Hello,
I have a function that wants a char* as a parameter. I want to pass it a structure, and then traverse it with pointer addition, for example if the first field in the structure was a short and i wanted to get to the second I would do something like:

char *passed_in_value *= (4 * sizeof(BYTE));

Is something like this possible? I guess the real question is, is it possible to get a char* to a structure and treat it as a long array or list of characters.

thanks
 
Yes, you need to cast it using reinterpret_cast<char*>.

However, if your function really takes a struct instead of a char* then you should change your function so it takes the proper type.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top