arrays - What is this pointer in C? -



arrays - What is this pointer in C? -

i have seen lot of these types, have no thought means

unsigned char somevar[maxlen]; int *ptr = (int *) somevar;

can explain?

it's somevar interpreted sequence of int's (or one) through ptr pointer. incrementing ptr 1 time moves pointer sizeof(int) bytes ahead.

be aware of endianness when doing conversions these. bytes somevar may need reordering interpreted ints.

also create sure somevar of length that's multiple of sizeof(int), otherwise undefined behaviour when trying access lastly int since partially available.

c arrays pointers char

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -