pack heterogeneous data types

A

ashokbellur

Hello,

How do i pack different data types into a struct or an array. Examples
would be helpful.

Say i need to pack an unsigned char( 0xFF) and an long( 0xAAAAAAAA)
into a single array? The reason i need to do this is send a packet over
a network.

Thanks,
-AB
 
C

Christopher Subich

Hello,

How do i pack different data types into a struct or an array. Examples
would be helpful.

Say i need to pack an unsigned char( 0xFF) and an long( 0xAAAAAAAA)
into a single array? The reason i need to do this is send a packet over
a network.

Look at the struct module, struct.pack sounds like what you need.
 
D

Diez B. Roggisch

Hello,

How do i pack different data types into a struct or an array. Examples
would be helpful.

Say i need to pack an unsigned char( 0xFF) and an long( 0xAAAAAAAA)
into a single array? The reason i need to do this is send a packet over
a network.

You've been reposting this on a frequent base all the time for 2 weeks
now - and everytime you've been told (by me and others) to use the
module struct. So - how about actually trying so and come back if you
hit the wall with that for whatever reason instead of unsuccsessfully
shoehorning arrays int something you think they're supposed to be?
Which, BTW, they aren't in _any_ language, as the are homogenous by
nature and only pointer-tricks in C can get you around that.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top