I don't understand some old C array concatenation -


i don't understand syntax in old c program, , not set test code see does. part confused concatenation array. didn't think c handle auto-typecasting that, or making difficult in head being friday afternoon...

char wrkbuf[1024]; int r; //some other code //below, vrec 4 byte struct memcpy( &vrec, wrkbuf + r, 4 ); 

any idea happen here? wrkbuf become when concatenate or add int it?

wrkbuf + r same &wrkbuf[r]

essentially wrkbuf when used in expression wrkbuf + 4 "decays" pointer first element. add r it, advances pointer r elements. i.e. there's no concatenation going on here, it's doing pointer arithmetic.

the memcpy( &vrec, wrkbuf + r, 4 ); copies 4 bytes wrkbuf array , starting @ rth element memory space of vrec


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -