meta data for this page


This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
courses:ct30a5002:packingdata [2013/09/19 14:46]
julaakko created
courses:ct30a5002:packingdata [2013/09/23 18:51] (current)
Line 1: Line 1:
 +===== Packing data to character buffer =====
 +In previous years some people had problems with packing integers to character buffers so here is an example about how to do it. Just remember to keep track of the amount of bytes each integer reserves from the buffer used for storing data. <code c>
 +*(uint16_t*)&​buffer_holding_data[position_to_store] = htons(value_to_store);​
 +uint16_t retrieved_value = ntohs(*(uint16_t*)&​buffer_holding_data[position_from_to_retrieve]);​
 +[[courses:​ct30a5002:​start#​code_snippets|CT30A5002 - Games and Networking]]