Why student1is not 8 and student4 is not 6? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Why student1is not 8 and student4 is not 6?

https://code.sololearn.com/csrSqk1YGFxN/?ref=app

26th Sep 2019, 10:28 PM
UraL
2 Respuestas
+ 1
Integers and structures want to be aligned to 4 byte chunks so student1's field a starts at one, b skips to the next to be aligned, c starts at the third, and the structure grabs the rest of it for 12 bytes. student4 is similar to student1, but you forced the structure to not grab the 3 bytes to end with a 4 byte multiple. Put the int first and it will yield 6 bytes.
28th Sep 2019, 10:36 PM
John Wells
John Wells - avatar
+ 1
John Wells good answer !!!!
29th Sep 2019, 2:20 AM
UraL