Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Typecasting char pointer to structure

Reply
Thread Tools

Typecasting char pointer to structure

 
 
venkatesh
Guest
Posts: n/a
 
      12-06-2003
Hi Members,

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

thanks in advance
venkat
 
Reply With Quote
 
 
 
 
lallous
Guest
Posts: n/a
 
      12-06-2003
"venkatesh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
when is typecasting (unsigned char*) to (char*) dangerous? tim C Programming 40 02-01-2012 06:12 AM
copy from a structure pointer the char array member to a char * VasandGVD C Programming 5 11-28-2008 11:25 PM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
when is typecasting (unsigned char*) to (char*) dangerous? b83503104 C Programming 1 06-21-2004 09:53 PM



Advertisments