[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Interview Questions and Answers :: Cisco

6. Is it possible to print sizeof bit field operator and why?

Answer:

#include <stdio.h>

#pragma pack(2)   

// if above line of code will be there then memory alignment boundry will be set to 2 so size of below will come as 2, else 4 byte.

int main()

{

    typedef struct

    {

        unsigned int x:1

    } x;

    printf("size of bitfield struct %d ",sizeof(x));

    return 0;

}

Post Your Answer Here:      Public      Private

Rate This: +0 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here