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.

1
  • 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 Commented May 11, 2011 at 5:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Mario, can u give me an example of that

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.