Introduction to Unions in C

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ค. 2024
  • C Programming: Introduction to Unions in C Programming.
    Topics discussed:
    1) Definition of unions in C.
    2) Examples of union.
    3) Size of union.
    4) Accessing the members of the union using pointers.
    C Programming Lectures: goo.gl/7Eh2SS
    Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
    Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
    Contribute: www.nesoacademy.org/donate
    Memberships: bit.ly/2U7YSPI
    Books: www.nesoacademy.org/recommende...
    Website ► www.nesoacademy.org/
    Forum ► forum.nesoacademy.org/
    Facebook ► goo.gl/Nt0PmB
    Twitter ► / nesoacademy
    Music:
    Axol x Alex Skrindo - You [NCS Release]
    #CProgrammingByNeso #CProgramming #UnionsInC #Structure&Union

ความคิดเห็น • 125

  • @igaimerca
    @igaimerca 3 ปีที่แล้ว +51

    I like how you explain straight to the point. No time wastage :) Less time searching and more time learning. Keep up the good work

  • @NOGAMENOLIFEGAMING
    @NOGAMENOLIFEGAMING 4 ปีที่แล้ว +41

    Thank you sir, can you please upload presentations about :
    -linked lists
    -trees
    -graphs

  • @Jodrie
    @Jodrie ปีที่แล้ว +7

    Thank you, this made it so much clearer than anything else I’ve seen!😄

  • @Omer-iv1wx
    @Omer-iv1wx 4 ปีที่แล้ว +2

    Interesting observation is that because the char value printed is the equivalent character encoding of the value stored in the first byte of memory allocated to store the union instance, you can print characters by making the integer value % 256 correspond to a character encoding. For example, the value of 65 in ASCII is 'A', which is why the first example resulted in printing 'A'. This can also be achieved if var.a = 65 + 256 * n, where n is any integer

  • @swapnareddy7079
    @swapnareddy7079 4 ปีที่แล้ว +4

    Excellent explanation sir....keep doing it sir...it would b really helpful to many of the students..👍👏😊

  • @cecon3315
    @cecon3315 3 ปีที่แล้ว +3

    incredible explanation, good job !

  • @simransohal9352
    @simransohal9352 2 ปีที่แล้ว +1

    Neso academy ur all videos are really helpful to me ur way of teaching is so good specially with examples it makes it too understandable

  • @WaterSea69
    @WaterSea69 4 ปีที่แล้ว +8

    Thank you
    Few words useful explanation

  • @mcbotface
    @mcbotface 4 ปีที่แล้ว +4

    Thank You Sir for such great videos.💕💖

  • @gamermonti1
    @gamermonti1 6 หลายเดือนก่อน +1

    thank you sir!!! you explained union very well while no one explaine like this

  • @mudassarsiddiqui4112
    @mudassarsiddiqui4112 2 ปีที่แล้ว +1

    Excellent explanation sir ❤❤
    Make more such videos on multiple choice questions...
    I am learning from your videos 👍👍

  • @nicog3583
    @nicog3583 2 ปีที่แล้ว +1

    Perfect explanation, thank you!

  • @radumichael-programming6924
    @radumichael-programming6924 3 ปีที่แล้ว +1

    Thank you! You are explaining very well

  • @Bharathkumar-ts2lr
    @Bharathkumar-ts2lr 2 ปีที่แล้ว

    Thank you sir. Recalled the concept of union in fraction of mins .

  • @kunalsoni7681
    @kunalsoni7681 4 ปีที่แล้ว +1

    wow awesome sir.. seriously very nice presentation

  • @amirmahdi_s6343
    @amirmahdi_s6343 3 ปีที่แล้ว +1

    Thanks a lot for your clear and nice presentations

  • @abdurrahmangovercin4057
    @abdurrahmangovercin4057 4 ปีที่แล้ว +1

    Very clear. thank you sir.

  • @Pratham_-xs5ss
    @Pratham_-xs5ss 2 ปีที่แล้ว +3

    No timepass ,
    Only to the point , perfect lecture

  • @angelobuoro
    @angelobuoro 4 ปีที่แล้ว +1

    Excelent! Thanks!

  • @Zen-lz1hc
    @Zen-lz1hc 2 ปีที่แล้ว +1

    That was a really good explanation.
    Thanks Man!

  • @krishshah3974
    @krishshah3974 3 ปีที่แล้ว

    amazing! so precise :D

  • @joaopedrorodrigues9281
    @joaopedrorodrigues9281 ปีที่แล้ว

    Very helpful video, thank you!

  • @thomas99971
    @thomas99971 2 ปีที่แล้ว

    perfect explanation, thank you

  • @naboulsikhalid7763
    @naboulsikhalid7763 8 หลายเดือนก่อน

    so clear and concise. thank you

  • @user-ho7bw7fj4q
    @user-ho7bw7fj4q ปีที่แล้ว

    Good explanation and easy to understand. Great job.

  • @mortezanaghavimoghadam8258
    @mortezanaghavimoghadam8258 ปีที่แล้ว

    This video really helps me and lets me learn the topic

  • @Vibe8dand16songs
    @Vibe8dand16songs 8 หลายเดือนก่อน

    Thank you for this presentation 🎉🎉

  • @te_b_52_siddeshpatankar14
    @te_b_52_siddeshpatankar14 3 ปีที่แล้ว +1

    Just brilliant 🙏🏻🙏🏻🙏🏻

  • @surajhiremath2199
    @surajhiremath2199 3 ปีที่แล้ว +2

    U teach soo clean and nicee😍

  • @PabloSanchez-th5em
    @PabloSanchez-th5em 3 ปีที่แล้ว

    Thank you so much!!

  • @1matzeplayer1
    @1matzeplayer1 ปีที่แล้ว

    This is top notch content!

  • @mainakmukherjee3444
    @mainakmukherjee3444 2 ปีที่แล้ว

    It's clear to me ❤️

  • @AbhishekSingh-cu1fe
    @AbhishekSingh-cu1fe 3 ปีที่แล้ว +2

    Best Explanation!

  • @onkarmehetre7393
    @onkarmehetre7393 2 ปีที่แล้ว

    Perfect explanation...!!!

  • @godgifted2694
    @godgifted2694 ปีที่แล้ว

    Your explanation is too better and simple way ❤

  • @haseen2412
    @haseen2412 ปีที่แล้ว

    This is perfection!

  • @keshavkumar5261
    @keshavkumar5261 3 ปีที่แล้ว

    Sir it's marvelous

  • @Idk0037
    @Idk0037 23 วันที่ผ่านมา

    tysm my dear neso academy

  • @NakshatraMeenayt
    @NakshatraMeenayt 2 ปีที่แล้ว +1

    Thanks sir your videos are really helpful for me

  • @abhisheks1887
    @abhisheks1887 2 ปีที่แล้ว +2

    sir if the union contains only int(4bytes)and float(4bytes), which datatype size will it consider and y ??
    Thank you.

  • @vikashkumarjaykar200
    @vikashkumarjaykar200 3 ปีที่แล้ว

    Thank you sir very good explanation

  • @rebeccayucana8919
    @rebeccayucana8919 3 หลายเดือนก่อน

    wonderful lesson

  • @bhavnapatnaik8822
    @bhavnapatnaik8822 4 หลายเดือนก่อน

    max information sharing within min tiime.👏

  • @thisisourworld6368
    @thisisourworld6368 2 ปีที่แล้ว

    you are great so helping

  • @kkkayschannel
    @kkkayschannel 3 ปีที่แล้ว

    Thank You!

  • @ManojKumar-bk1nf
    @ManojKumar-bk1nf ปีที่แล้ว

    Awesome explanation 👍

  • @MukeshKumar-rg1ie
    @MukeshKumar-rg1ie 2 ปีที่แล้ว

    Thanks a lot 🙏

  • @electricity2703
    @electricity2703 9 หลายเดือนก่อน

    Clean explaination

  • @deepakkushwaha-mq8wz
    @deepakkushwaha-mq8wz 4 ปีที่แล้ว +2

    Amezing videos on c programming.... Thanxx for making such a wonderful videos...

  • @ripalnakiya
    @ripalnakiya 3 ปีที่แล้ว

    Great channel

  • @rabiyathulbasiriya3688
    @rabiyathulbasiriya3688 2 ปีที่แล้ว

    Good explanation sir.tanq

  • @FunnyVideos-kc6xv
    @FunnyVideos-kc6xv 3 ปีที่แล้ว

    Thank you so much sir 💖💖

  • @manjunathn5251
    @manjunathn5251 ปีที่แล้ว

    You won @2:00 with the kind of explanation. Great 👏👏👏👏

  • @bindhushreeg1758
    @bindhushreeg1758 3 ปีที่แล้ว +1

    Very good video

  • @exoticcoder5365
    @exoticcoder5365 3 ปีที่แล้ว

    Thanks !

  • @mcbotface
    @mcbotface 4 ปีที่แล้ว +4

    please upload videos on nested structures Sir.🙏🙏🙏🙏

  • @736939
    @736939 3 ปีที่แล้ว

    ok, but if we create union as an object in the heap like: abc* var = new abc() then do they share the same memory?

  • @RahKale
    @RahKale 3 หลายเดือนก่อน

    Nice explanation

  • @zaheddeshmukh8238
    @zaheddeshmukh8238 4 ปีที่แล้ว +1

    Very nice sir

  • @abinashhandique4206
    @abinashhandique4206 2 ปีที่แล้ว

    Best representation ever I watched..

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 2 ปีที่แล้ว

    Thanks 😊

  • @Lemon-xw7ds
    @Lemon-xw7ds ปีที่แล้ว

    love it 🍋

  • @madhavkrishna4961
    @madhavkrishna4961 2 ปีที่แล้ว

    Like
    Straight from the text book.
    Too good...

  • @bcastudent8092
    @bcastudent8092 ปีที่แล้ว

    nice explain sir💯💯💯

  • @saidaouyous3485
    @saidaouyous3485 3 ปีที่แล้ว

    thank u so much

  • @pakkakivelliaadukoamma1369
    @pakkakivelliaadukoamma1369 3 ปีที่แล้ว

    Sir, please upload the videos on tress and graphs

  • @AbdelbariBenKamel
    @AbdelbariBenKamel 4 หลายเดือนก่อน

    Hello, thank you for the informative video. It has proven to be quite useful. However, I'm curious whether the size of an element type remains consistent across all programming languages, and whether processors require the same number of cycles to access variables regardless of the language used. Could you clarify this point?

  • @chingkhei_thoudam
    @chingkhei_thoudam 3 ปีที่แล้ว +1

    Why the value of a is printed? Isn't the memory of a be overwritten by b as b executed later?

  • @AshuSingh-us5tp
    @AshuSingh-us5tp 4 ปีที่แล้ว +2

    It's a request to this channel..
    Please upload lectures regarding "design and analysis of algorithm" (DAA) as it's my 5th sem subject & exams are near (approx 3 months) . It's a cs subject as well as gate's too.. Please help.. Sir

  • @user-bu8mg7uq3s
    @user-bu8mg7uq3s 3 ปีที่แล้ว

    thank you

  • @exoticcoder5365
    @exoticcoder5365 3 ปีที่แล้ว

    Useful

  • @hadireg
    @hadireg 3 ปีที่แล้ว +3

    I'm an old time C programmer, I totally understand what unions are and how all its members share the same memory location and its size is the size of the biggest member in the union. the remaining question is WHY for? never found a convincing answer... I had sometimes a need to create unions, and for my case it was ONLY to be used as a temporary "pseudo structure" and to manipulate a member in temporary way taking advantage of the pointer's addressing technique. I still don't see any motivation to their creation at the first place other than what I used them for.

    • @purubhargava8096
      @purubhargava8096 3 ปีที่แล้ว +1

      bro if you got answer plz reply back as i also thought oh=f same thing plz reply

  • @TheUniqueCoder
    @TheUniqueCoder 4 ปีที่แล้ว +4

    Please make seris on c++

  • @saikrishnathota5972
    @saikrishnathota5972 4 ปีที่แล้ว +1

    Please upload network theory classes sir

  • @dhaneshprabhu72
    @dhaneshprabhu72 3 ปีที่แล้ว

    Can union have a struct as it's member

  • @sz4746
    @sz4746 2 ปีที่แล้ว

    Does the example work only on little endian machines? Because for large endian machines, 1 is like 0x 00 00 00 01 instead of 0x 01 00 00 00

  • @cyrilemeka6987
    @cyrilemeka6987 ปีที่แล้ว

    There was nothing vague in this video. Continue the good work

  • @indian3451
    @indian3451 4 ปีที่แล้ว +4

    please do on Dynamic Memory Allocation

    • @anonemoose102
      @anonemoose102 3 ปีที่แล้ว +1

      like how your name's jus indian lol

  • @shubhamkandekar4723
    @shubhamkandekar4723 2 ปีที่แล้ว

    can a pointer be a union member?

  • @amwamique
    @amwamique ปีที่แล้ว +1

    Arrow operator is also known as Reference operator.

  • @llll-qz9kr
    @llll-qz9kr 3 ปีที่แล้ว

    Disadvantages of union
    You can use only one union member at a time.
    All the union variables cannot be initialized or used with varying values at a time.
    Union assigns one common storage space for all its members.
    seems basically a union is = one of the variables in the union
    rather than actually being or holding all the variables setup for the union, it gets the memory for the biggest type
    and then depending on which variable you're accessing, it will basically be only that variable - so when you change the value
    the other variables values change as well, cuz they're really all the same, stored in the biggest types amount of memory and address
    but the depending on what you're working with, it will work as if it is that type..
    like struct != a & b & c .. struct = a | b | c .. close? lul
    .. I think I got close at least :)

  • @sagarraj4521
    @sagarraj4521 4 ปีที่แล้ว

    What if var.a = 129 ? I mean to say what will be displayed for char if no ASCII corresponding is not there...?

    • @vishallondhe7298
      @vishallondhe7298 4 ปีที่แล้ว +3

      www.onlinegdb.com/online_c_compiler here's your answer.

    • @virajpotdar8104
      @virajpotdar8104 3 ปีที่แล้ว

      @@vishallondhe7298 🤣🤣🤣🤣

  • @undercrackers56
    @undercrackers56 7 หลายเดือนก่อน

    Sir, I think you have set the standard on how to present computer programming topics.

  • @bhaweshkathayat7033
    @bhaweshkathayat7033 ปีที่แล้ว

    Sir please bring a web development course

  • @trilecao9014
    @trilecao9014 3 ปีที่แล้ว

    Thanks 0:22

  • @KushagraSinghhh
    @KushagraSinghhh 3 ปีที่แล้ว +3

    Very helpful . Just a suggestion : Please attach the link for the slides also in the description box.

  • @harshrana2004
    @harshrana2004 4 ปีที่แล้ว

    Voice!

  • @SportsGyan_
    @SportsGyan_ 3 ปีที่แล้ว

    no its showing of different memory...

  • @hacxngrafit4323
    @hacxngrafit4323 ปีที่แล้ว +4

    Too much efforts

  • @lequangthinh4279
    @lequangthinh4279 ปีที่แล้ว

    Can every one help me why the size of union_data is 16, why it is not 9?
    #include
    using namespace std;
    union unionData
    {
    long longData;
    char charArray[9];
    };
    int main()
    {
    unionData union_data;
    cout

    • @garjura4659
      @garjura4659 ปีที่แล้ว

      I thought this was C tutorial not C++.

  • @yagneshbhadiyadra1314
    @yagneshbhadiyadra1314 4 ปีที่แล้ว +1

    Like we are deaf, why say same thing thrice written on the slide? -_- 0:00 to 0:34
    Overall nice video, Kudos🤘

    • @vikramkrishna8780
      @vikramkrishna8780 4 ปีที่แล้ว +8

      Bruv, not everyone got the qucik grasping technique. Each time he says it, he stresses it and hence people get to know the keywords.

  • @martinzderadicka8280
    @martinzderadicka8280 3 ปีที่แล้ว +1

    you have a milion subs? hooly shit

  • @merlahari1655
    @merlahari1655 4 ปีที่แล้ว +3

    It's me 1st view and 1st comment

  • @sheharyarnoor2988
    @sheharyarnoor2988 2 ปีที่แล้ว

    Gg

  • @waterisgood2051
    @waterisgood2051 3 ปีที่แล้ว +20

    i dont know why there are so many indians doing tutorials about c, i dont want to be mean, i dont hate them or something but i just cant understand they re accent and its anoying, but honestly this is the first person that taught me something, and i could understand him,so thank you!

    • @zububabu8249
      @zububabu8249 ปีที่แล้ว +14

      Dude if u feel it's annoying them keep walking instead of commenting about it it's not something one can help be greatfull that they are teaching u something in detail that too

    • @zububabu8249
      @zububabu8249 ปีที่แล้ว +9

      Not everyone can speak multiple languages an average indian speak 4-5 language so yeah u can't have perfect accent and tend to do grammatical mistake

    • @om7g.103
      @om7g.103 ปีที่แล้ว +1

      You don't understand our language Moron ... And your people can't even make C Language videos .....
      We can Understand your stupid English but you can't understand our Hindi ......
      And we have created such wonderful videos in English for free for you assholes..... And you still have the problem with Accent .... Shame on you...can't you just adjust with our content you dickhead ...... We could have also set international Restrictions over our videos.....

    • @akshayjadhav75
      @akshayjadhav75 ปีที่แล้ว +9

      They do it for people like you and your fellow countrymen who struggle to understand C lang.

    • @waterisgood2051
      @waterisgood2051 ปีที่แล้ว

      @@akshayjadhav75 I assume you learned by yourself. Just opening code blocks, and started writing stuff, and just understood it right?

  • @onkarmehetre7393
    @onkarmehetre7393 2 ปีที่แล้ว

    Perfect explanation...!!!