3

Possible Duplicates:
How to convert struct to char array in C
Portable way of writing a C struct to a file (Serialisation for C)

I am looking for converting a structure to byte array in C and i was confused in doing that.Please show me a right way in achieving that. Thanks in advance.

Community
  • 1
  • 1
venkatesh
  • 31
  • 1
  • 4
  • i have a simple structure populated with integers, floats and one more struct inside, i need that structure to be converted in to a byte array which to be used in jni – venkatesh May 11 '11 at 05:25

1 Answers1

1

A structure is a byte array. it starts at &mystruct and has the length of sizeof(mystruct_type) bytes.

If the binaries are to long or do contain gaps, check the #pragma pack settings.

hth

Maro

Mario The Spoon
  • 4,799
  • 1
  • 24
  • 36