This question already has answers here:
What is the strict aliasing rule?
(11 answers)
Closed 6 years ago.
What really happens if we write 4 times 1B of char with 8bit pointer, and then we read that 4B with 32bit pointer? Why this is not recommended, what can happen?
When you read the 32bits back as an integer you get the integer representation of whatever you wrote.
What you have described is a technique commonly used to deserialize binary data. The reverse procedure will serialize the data.
Related
This question already has answers here:
Can someone explain hex offsets to me?
(6 answers)
Closed 8 years ago.
I'm trying to understand what an offset in a hex dump is. In particular, what purpose does an offset serve? I have googled many times but not found anything.
The offset describes where something is in the file. You can obtain and jump to offsets in code using lseek(2) or fseek(3), depending on which I/O system you're using.
This question already has answers here:
Store and work with Big numbers in C
(3 answers)
Closed 8 years ago.
I want to store a number "x" where 0<=x<=(10^18).
Which datatype should be used in C for storing such a large number?
I used "long int" but it's not working..
Use unsigned long long int. It is supported in C99 or later, and as a compiler extension in some pre-1999 compilers. and it must be able to hold at least 1.8 * 10^19 values.
This question already has answers here:
what is meant by normalization in huge pointers
(3 answers)
Closed 9 years ago.
Actually i was studying about huge and far pointers.
I come to know huge pointers are by default in normalized form.
I want to know how can we normalize any pointer?
The huge pointer and far pointer are old concept which live in 16-bit
DOS time. You can search something about DOS programming for more
detail about them.
In 8086 programming (MS DOS), a far pointer is normalized if its offset part is between 0 and 15 (0xF).
This question already has answers here:
Closed 11 years ago.
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.
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
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is void* and to what variables/objects it can point to
What does void* represent in C?
Please give a reason for the use, too...
void * is a "typeless" pointer in C, that is, a pointer that may point to an object of any type. It is used if one does not know the type of the data to be stored beforehand.