By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

Typecasting char pointer to structure

P: n/a
Hi Members,

I need to convert Char Pointer to a Structure.How Can i typecast this.

thanks in advance
venkat
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"venkatesh" <ve*********@yahoo.co.in> wrote in message
news:b2**************************@posting.google.c om...
Hi Members,

I need to convert Char Pointer to a Structure.How Can i typecast this.
thanks in advance
venkat


struct MyStruct
{
int a, b, c;
};

int main()
{
char *ptr;
MyStruct *pstruct;

// C++ casting
pstruct = reinterpret_cast<MyStruct *>(ptr);
// or C style casting:
pstruct = (MyStruct *)ptr;

return 0;
}

Regards,
Elias
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.