Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Typecasting char pointer to structure (http://www.velocityreviews.com/forums/t279803-typecasting-char-pointer-to-structure.html)

venkatesh 12-06-2003 05:30 AM

Typecasting char pointer to structure
 
Hi Members,

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

thanks in advance
venkat

lallous 12-06-2003 06:46 AM

Re: Typecasting char pointer to structure
 
"venkatesh" <venkat2k_vb@yahoo.co.in> wrote in message
news:b259f1ac.0312052130.2e045482@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




All times are GMT. The time now is 07:17 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.