Let me start by saying that I openly admit this is for a homework assignment, but what I am asking is not related to the purpose of the assignment, just something I don't understand in C
. This is just a very small part of a large program.
So my issue is, I have a set of data that consists various data types as follows:
[16 bit number][16 but number][16 bit number][char[234]][128 bit number]
where each block represents a variable from elsewhere in the program.
I need to send that data 8bytes
at a time into a function that accepts uint32_t[2]
as an input. How do I convert my 234byte char array
into uint32_t
without losing the char
values?
In other words, I need to be able to convert back from the uint32_t
version to the original char array
later on. I know a char
is 1byte
, and the value can also be represented as a number in relation to its ascii value, but not sure how to convert between the two since some letters have a 3 digit ascii value and others have 2.
I tried to use sprintf
to grab 8byte
blocks from the data set, and store that value in a uint32_t[2]
variable. It works, but then I lose the original char array
because I can't figure out way to go back/undo it.
I know there has to be a relatively simple way to do this, i'm just lacking enough skill in C
to make it happen.