Question:

In a C struct, what does the expression "int i : 5" mean?

by  |  earlier

0 LIKES UnLike

In a C struct, what does the expression "int i : 5" mean?

 Tags:

   Report

2 ANSWERS


  1. It means i will occupy 5 bits of an int. Which 5 bits, however, depends on what else is in the struct.

    For example:

    typedef struct {

       int i : 5;

       int j : 3;

       int k : 24;

    } BitFields;

    sizeof(BitFields) = sizeof(int).

    i occupies bits 0 through 4

    j is in bits 5 through 7

    k in bits 8 through 31


  2. It means i defined as a 5 bits integer.

    peng

    http://www.eptop.com

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions