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

pack heterogeneous data types

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
as*********@gmail.com wrote:
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.
Jul 19 '05 #2

P: n/a
as*********@gmail.com wrote:
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
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.