Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

These two methods will yield different results.  The first produces 0x0110 = 272 as we would expect.  The second produces 0x1001 = 4097 because we're working on a little-endian system.  On a big endian system the second method would give us the same result as the first.  

Neither one of these solutions is very elegant though, especially if we start to deal with longer arrays or larger numbers.  One solution is to use structs to send your data.  A struct can be defined that holds all the data you want to send and then memcpy can copy the whole thing to or from an array in one go.