On a 32-bit x86 machine: typedef struct { union { unsigned char a; unsigned short b; } U; unsigned char c; } S; S B[10]; S *p = &B[4]; S *q = &B[5]; p->U.b = 0x1234; (S takes 32 bits). If M is q − p and N is (int)&(p->c) − (int)p, then (M, N) is
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. (1, 2)
Explanation
q − p counts elements, so M = 1. The union takes 2 bytes (a short), so c sits at byte offset 2: N = 2.
More Programming Languages and Computer Graphics questions
- Class Good has a field m and a method public boolean equals(Good n) { return n.m == m; }. In main: Good m1 = new Good(22), m2 = new Good(22…
- Consider the following function ) : f n unsigned int (unsigned int )( b = 0 unsigned int ; while (n) { b+ = n&1 ; n ≫>= 1 ; } return b;} ``…
- Consider a raster system with resolution 640 by 480 . What size is frame buffer (in bytes) for this system to store 12 bits per pixel?
- Consider the following statements regarding 2D transforms in computer graphics: 1 0 [ ] 2 × 2 S1 : is a matrix that reflects 0 −1 2D X (mir…
- In the context of 3D computer graphics, which of the following statements is/are true? P : Orthographic transformations keep parallel lines…
- Using the phong reflectance model, the strength of the specular highlight is determined by the angle between