TL DR: this code is bad, forget about it and move on.
(buffer) This bracket means that the programmer is not confident in his own programming abilities.
Since buffer is an array of characters, the buffer identifier itself gives you a pointer to the first element: a char pointer.
(int*) This is a cast, converting a char pointer to an int pointer.
* takes the contents of this integer pointer, and the result is stored in integer size .
Please note that this code is completely dangerous. Many pointer conversions cause bad behavior. There may be alignment problems. There may be problems with pointer aliases (Googleβs strict anti-aliasing rule). This particular code also depends on the sequence, meaning that it requires that the contents of the character array have a given byte order.
In general, it makes no sense to use signed types, such as int or char (possibly signed), when performing such actions. In particular, the char type is very problematic since it has a signature defined by the application and should be avoided. Use unsigned char or uint8_t .
A slightly less bad code would look something like this:
#include <stdint.h> uint8_t buffer[4096]; // some code uint32_t size = *(uint32_t*)buffer;
source share