Bit Fields In C & C++

Поділитися
Вставка
  • Опубліковано 14 гру 2024

КОМЕНТАРІ • 107

  • @hindiistoriess
    @hindiistoriess Рік тому +1

    Thank you 🙏🏻 for explaining in detail... Now I understood fully about bit fields

  • @treyquattro
    @treyquattro 4 роки тому +3

    I appreciate the work you put into these videos and your professorial style. The videos are a great resource for newbies and also as a refresher for some of us who like to keep our memories refreshed!

    • @CppNuts
      @CppNuts  4 роки тому +1

      Thanks man!!

  • @janupenaganti4951
    @janupenaganti4951 9 місяців тому

    I have started my career in Embedded Systems, this topic is really helpful for me. Thank you!!

  • @nishantgarg5324
    @nishantgarg5324 6 років тому +10

    Nice illustrate. Keep it up.

    • @CppNuts
      @CppNuts  6 років тому

      Thanks Dude!!

  • @sabanaafrose7293
    @sabanaafrose7293 6 років тому +4

    Superb... Keep doing... The way you explained the flow and the sequence ... Everything made me hit like ..if I could I would hit it many times.... Thank a lot

    • @CppNuts
      @CppNuts  6 років тому

      Sabana Afrose, Thanks for your like and nice comment.

  • @Gautamdange
    @Gautamdange 5 років тому +1

    Really liked your videos .. simple .. short and to the point !

    • @CppNuts
      @CppNuts  5 років тому

      Thanks.. Man..!!

  • @sambasivamupparaju
    @sambasivamupparaju 6 років тому +8

    good explanation.
    Thank you for your effort .

    • @CppNuts
      @CppNuts  6 років тому

      Thank man:!!

  • @vimleshkumarkanaujiya
    @vimleshkumarkanaujiya Рік тому

    Arey Bhaiya, What an easy way of teaching !.

  • @ViratKohli18_Lovers
    @ViratKohli18_Lovers 6 років тому +2

    You explained it very well sir. I understood everything about bit field.

    • @CppNuts
      @CppNuts  6 років тому

      That's great!!

  • @pandemade3875
    @pandemade3875 4 роки тому +1

    Thank you so much! This really helps me understand bit field in more detail! Thank you!

    • @CppNuts
      @CppNuts  4 роки тому

      Glad that it helped.

  • @ShashidharM-h9v
    @ShashidharM-h9v Рік тому

    8:51 sir, Why structural packing doesn't work in the above example it still give 8 bytes of size
    On adding #pragma pack(1)

  • @shibisaketh
    @shibisaketh 5 років тому +1

    unsigned int day : 5;
    unsigned int month : 4;
    int year : 22;
    So can reduce the size again.
    Size : 4

    • @CppNuts
      @CppNuts  5 років тому

      Yes you can further use the same int for 1 Bit because 5+4+22 = 31 and int is 32 bits.

  • @Olavotemrazaodenovo
    @Olavotemrazaodenovo 4 роки тому +1

    Congratulations from Brazil.

  • @KumarGaurav159
    @KumarGaurav159 6 років тому +1

    It was very helpful and I request to upload a tutorial regarding forward declaration in c++ in details and with depth analysis.thanks .

    • @CppNuts
      @CppNuts  6 років тому +1

      I am trying my best to upload as much as i can but i will keep this suggestion in my mind thanks dude!! :)

  • @aadarshraj5859
    @aadarshraj5859 2 роки тому +1

    Very nice explanation. Thanks to you

  • @1-User-1
    @1-User-1 5 років тому +1

    Best explanation of Bit Fields.

    • @CppNuts
      @CppNuts  5 років тому +1

      Thanks for the comment man!!

    • @1-User-1
      @1-User-1 5 років тому +1

      @@CppNuts thank you for your video!

  • @vvpChannel3112
    @vvpChannel3112 5 років тому +1

    Awesome video sir.. I learnt something new here...many thanks ..please make more videos on memory optimisation

    • @CppNuts
      @CppNuts  5 років тому

      Sure man i will try for this video.

  • @vipuldogra6600
    @vipuldogra6600 4 роки тому +1

    beautifully explained. thanks

  • @soumyaranjansahu7018
    @soumyaranjansahu7018 5 років тому +1

    Awesome explanation...😊👍

  • @maratheps1new237
    @maratheps1new237 3 роки тому

    sir your all cpp videos are great ^^

    • @CppNuts
      @CppNuts  3 роки тому

      Glad you like them!

  • @karthikkumarmv9101
    @karthikkumarmv9101 5 років тому +1

    So nice and effective explanation Sir tq. ...

    • @CppNuts
      @CppNuts  5 років тому

      Thanks bro..

  • @mohanrajawat6508
    @mohanrajawat6508 4 роки тому +1

    very nice discription

  • @sss-og7jx
    @sss-og7jx 2 роки тому

    Very Clear! Thank U!

  • @rajcodes100
    @rajcodes100 6 років тому +2

    Great explanations - thank you

    • @CppNuts
      @CppNuts  6 років тому

      Thanks for your comment!!

  • @justcurious1940
    @justcurious1940 Рік тому

    struct date {
    unsigned char day : 5 ;
    unsigned char month : 4 ;
    unsigned char year ;
    } ;
    printf("sizeof struct date : %d
    ",sizeof(struct date)) ; // output is 3
    i'm using gcc default compilation .

    • @CppNuts
      @CppNuts  Рік тому +1

      Year one byte
      Day + month is 2 bytes, because 5+4 is 9 bits which is more than one byte.

    • @justcurious1940
      @justcurious1940 Рік тому

      @@CppNuts Thank u for replying, my confusion was that the size of( struct date) is not a power of 2 or a multiple of 2, I thought that objects in C always occupies a space in memory that is either a power of 2 or a multiple of 2.

    • @CppNuts
      @CppNuts  Рік тому +1

      That is multiple of biggest data member in class or struct.

    • @justcurious1940
      @justcurious1940 Рік тому

      @@CppNuts yes, Thank u I get it now.Great video by the way, so much information gained.

  • @shiwanisingh3152
    @shiwanisingh3152 6 років тому +2

    Very helpful sir
    Thank you sir

    • @CppNuts
      @CppNuts  6 років тому

      Most welcome!!

  • @shivamsaxena5854
    @shivamsaxena5854 4 роки тому

    #include
    #include
    struct d0
    {
    char vo : 3;
    int v1 : 7;
    };
    int main()
    {
    printf("%d", sizeof(struct d0));
    return 0;
    }
    I thought that I shall get 4 bytes as output as 32 bits (size of larger data type i.e; int) are enough to store 3 bits of char and 7 bits of int data type, But instead, I'm getting 8 bytes as output.
    Please tell me why I am getting so?
    Please answer @CppNuts

  • @abdullahgarra8477
    @abdullahgarra8477 Рік тому

    Hi, I have an interview and the interviewer said I should be handy with bitfields
    where can i see questions ?

    • @CppNuts
      @CppNuts  Рік тому

      I have bit field questions series plz check that out.

  • @AshokKumar-mk1nr
    @AshokKumar-mk1nr 4 роки тому +1

    Awesome explanation..

  • @hitendrapalsinghrao3436
    @hitendrapalsinghrao3436 6 років тому +1

    What is the software you are using?

  • @AhmedKhaled72
    @AhmedKhaled72 4 роки тому

    The best teacher out there 😍😍

  • @ofirfr4804
    @ofirfr4804 4 роки тому

    Very good explanation.
    I learned a lot.

    • @CppNuts
      @CppNuts  4 роки тому

      Glad it was helpful!

  • @mdirshadalam2617
    @mdirshadalam2617 5 років тому +1

    How will allocate 16 bytes or 32 bytes in bit fields or large size?
    I need this very much.Please explain

    • @CppNuts
      @CppNuts  5 років тому

      Please explain more, couldn't understand your question?

    • @mdirshadalam2617
      @mdirshadalam2617 5 років тому +1

      @@CppNuts Is there any restriction for allocating bit in bit fields?
      Means, how many bits to allocate in bit field or no restriction.

    • @CppNuts
      @CppNuts  5 років тому +1

      Yes it is max of the type used. For more check this stackoverflow.com/questions/14553632/maximum-size-of-a-bit-field-in-c-or-c

    • @mdirshadalam2617
      @mdirshadalam2617 5 років тому

      @@CppNuts Thank

  • @Easy369-wcb
    @Easy369-wcb 4 роки тому

    can you help me with allocating memory for black ops 3 for a mod. I want to add more assets into attachmentunique

  • @Agogogogogogkglgkfndjesk
    @Agogogogogogkglgkfndjesk 5 років тому +1

    thank you for the explanation sir

    • @CppNuts
      @CppNuts  5 років тому

      You are welcome dude..

  • @_shubham_kumar
    @_shubham_kumar 4 роки тому +1

    Great video. But I don't understand why we can't have static variables with bit fields?

    • @CppNuts
      @CppNuts  4 роки тому

      Why do you want that?

  • @mukundshahiitr7113
    @mukundshahiitr7113 3 роки тому

    Nice explaination☺☺

    • @CppNuts
      @CppNuts  3 роки тому

      It's my pleasure

  • @SYALUS3
    @SYALUS3 6 років тому +1

    Very good explanatuion... But one doubt actually we couldn't use that saved memory. Then why....

    • @CppNuts
      @CppNuts  6 років тому

      Notice that when we didn't use bit fields size was 12 but when we used bit fields then size became 8.

  • @satishkanakappanavar8531
    @satishkanakappanavar8531 5 років тому +1

    Thank you

    • @CppNuts
      @CppNuts  5 років тому

      Satish, welcome dude.

  • @cid007007
    @cid007007 4 роки тому

    Great tutorial.. learnt alot.. :)

  • @jaganmohanroyalnanubala3095

    Loved it 💕

  • @bilgetaskn9428
    @bilgetaskn9428 4 роки тому

    it was amazing.. thank you so much

    • @CppNuts
      @CppNuts  4 роки тому

      Glad you liked it!

  • @ShivamSingh-ub9tg
    @ShivamSingh-ub9tg 6 років тому +1

    nice tut.
    :)

    • @CppNuts
      @CppNuts  5 років тому

      Thanks man!!

  • @amitpandey4566
    @amitpandey4566 6 років тому +1

    great as always

    • @CppNuts
      @CppNuts  6 років тому

      Thanks dude!!

  • @tahirm09
    @tahirm09 6 років тому +1

    hi, voice is not clear pl check

    • @CppNuts
      @CppNuts  6 років тому

      At what point did you feel that? Please mention the timing in the video. Thanks

  • @prakashkondru5020
    @prakashkondru5020 3 роки тому

    Sir plz tell me your git hub . I will copy the code

    • @CppNuts
      @CppNuts  3 роки тому

      I am working on it.

  • @paul87173
    @paul87173 4 роки тому

    Hey Yadav, i'm learning c++ by myself. Any comments or tips you cud giv me? I have no money to go to university. But Still i want to be a programmer.

    • @CppNuts
      @CppNuts  4 роки тому

      Work hard like your life depends on it.

    • @paul87173
      @paul87173 4 роки тому

      @@CppNuts C'mon dude,please give me more props.I mean, your fav book, anyhobbies concerning c++, you know.. that sort of things.

    • @CppNuts
      @CppNuts  4 роки тому

      Doesn't really matter.

  • @WowPlusWow
    @WowPlusWow 2 роки тому +1

    🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼🙏🏼

  • @matheenshk
    @matheenshk 4 роки тому +1

    nice

  • @helloyou4233
    @helloyou4233 4 роки тому

    it was nice

  • @smartmiran
    @smartmiran 3 роки тому

    why does he need to place advertisement every 2 seconds, this is really annoying!!

  • @vasubansal8438
    @vasubansal8438 3 роки тому

    Voice is too less

    • @CppNuts
      @CppNuts  3 роки тому +1

      Sorry for that..