Introduction to Unions in C

Поделиться
HTML-код
  • Опубликовано: 20 май 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

Комментарии • 124

  • @igaimerca
    @igaimerca 3 года назад +47

    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 года назад +39

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

  • @Jodrie
    @Jodrie Год назад +5

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

  • @swapnareddy7079
    @swapnareddy7079 4 года назад +4

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

  • @WaterSea69
    @WaterSea69 4 года назад +8

    Thank you
    Few words useful explanation

  • @cecon3315
    @cecon3315 3 года назад +3

    incredible explanation, good job !

  • @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

  • @simransohal9352
    @simransohal9352 2 года назад

    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

  • @mcbotface
    @mcbotface 4 года назад +4

    Thank You Sir for such great videos.💕💖

  • @nicog3583
    @nicog3583 2 года назад +1

    Perfect explanation, thank you!

  • @mudassarsiddiqui4112
    @mudassarsiddiqui4112 2 года назад +1

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

  • @Pratham_-xs5ss
    @Pratham_-xs5ss Год назад +3

    No timepass ,
    Only to the point , perfect lecture

  • @Bharathkumar-ts2lr
    @Bharathkumar-ts2lr Год назад

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

  • @Zen-lz1hc
    @Zen-lz1hc 2 года назад +1

    That was a really good explanation.
    Thanks Man!

  • @radumichael-programming6924
    @radumichael-programming6924 3 года назад +1

    Thank you! You are explaining very well

  • @gamermonti1
    @gamermonti1 3 месяца назад

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

  • @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

  • @user-ho7bw7fj4q
    @user-ho7bw7fj4q 11 месяцев назад

    Good explanation and easy to understand. Great job.

  • @bhavnapatnaik8822
    @bhavnapatnaik8822 Месяц назад

    max information sharing within min tiime.👏

  • @te_b_52_siddeshpatankar14
    @te_b_52_siddeshpatankar14 3 года назад +1

    Just brilliant 🙏🏻🙏🏻🙏🏻

  • @mortezanaghavimoghadam8258
    @mortezanaghavimoghadam8258 Год назад

    This video really helps me and lets me learn the topic

  • @surajhiremath2199
    @surajhiremath2199 3 года назад +2

    U teach soo clean and nicee😍

  • @abdurrahmangovercin4057
    @abdurrahmangovercin4057 4 года назад +1

    Very clear. thank you sir.

  • @godgifted2694
    @godgifted2694 Год назад

    Your explanation is too better and simple way ❤

  • @joaopedrorodrigues9281
    @joaopedrorodrigues9281 Год назад

    Very helpful video, thank you!

  • @Vibe8dand16songs
    @Vibe8dand16songs 6 месяцев назад

    Thank you for this presentation 🎉🎉

  • @thomas99971
    @thomas99971 2 года назад

    perfect explanation, thank you

  • @naboulsikhalid7763
    @naboulsikhalid7763 6 месяцев назад

    so clear and concise. thank you

  • @AbhishekSingh-cu1fe
    @AbhishekSingh-cu1fe 2 года назад +2

    Best Explanation!

  • @angelobuoro
    @angelobuoro 4 года назад +1

    Excelent! Thanks!

  • @krishshah3974
    @krishshah3974 3 года назад

    amazing! so precise :D

  • @onkarmehetre7393
    @onkarmehetre7393 2 года назад

    Perfect explanation...!!!

  • @haseen2412
    @haseen2412 Год назад

    This is perfection!

  • @NakshatraMeenayt
    @NakshatraMeenayt 2 года назад +1

    Thanks sir your videos are really helpful for me

  • @manjunathn5251
    @manjunathn5251 Год назад

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

  • @keshavkumar5261
    @keshavkumar5261 3 года назад

    Sir it's marvelous

  • @1matzeplayer1
    @1matzeplayer1 Год назад

    This is top notch content!

  • @mcbotface
    @mcbotface 4 года назад +4

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

  • @madhavkrishna4961
    @madhavkrishna4961 2 года назад

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

  • @mainakmukherjee3444
    @mainakmukherjee3444 2 года назад

    It's clear to me ❤️

  • @PabloSanchez-th5em
    @PabloSanchez-th5em 3 года назад

    Thank you so much!!

  • @thisisourworld6368
    @thisisourworld6368 2 года назад

    you are great so helping

  • @vikashkumarjaykar200
    @vikashkumarjaykar200 3 года назад

    Thank you sir very good explanation

  • @electricity2703
    @electricity2703 6 месяцев назад

    Clean explaination

  • @abinashhandique4206
    @abinashhandique4206 2 года назад

    Best representation ever I watched..

  • @rebeccayucana8919
    @rebeccayucana8919 26 дней назад

    wonderful lesson

  • @ManojKumar-bk1nf
    @ManojKumar-bk1nf Год назад

    Awesome explanation 👍

  • @deepakkushwaha-mq8wz
    @deepakkushwaha-mq8wz 4 года назад +2

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

  • @MukeshKumar-rg1ie
    @MukeshKumar-rg1ie 2 года назад

    Thanks a lot 🙏

  • @rabiyathulbasiriya3688
    @rabiyathulbasiriya3688 2 года назад

    Good explanation sir.tanq

  • @RahKale
    @RahKale Месяц назад

    Nice explanation

  • @FunnyVideos-kc6xv
    @FunnyVideos-kc6xv 2 года назад

    Thank you so much sir 💖💖

  • @kkkayschannel
    @kkkayschannel 3 года назад

    Thank You!

  • @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

  • @bcastudent8092
    @bcastudent8092 Год назад

    nice explain sir💯💯💯

  • @ripalnakiya
    @ripalnakiya 2 года назад

    Great channel

  • @bindhushreeg1758
    @bindhushreeg1758 3 года назад +1

    Very good video

  • @AbdelbariBenKamel
    @AbdelbariBenKamel 2 месяца назад

    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?

  • @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.

  • @zaheddeshmukh8238
    @zaheddeshmukh8238 4 года назад +1

    Very nice sir

  • @exoticcoder5365
    @exoticcoder5365 3 года назад

    Thanks !

  • @Lemon-xw7ds
    @Lemon-xw7ds Год назад

    love it 🍋

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 2 года назад

    Thanks 😊

  • @pakkakivelliaadukoamma1369
    @pakkakivelliaadukoamma1369 3 года назад

    Sir, please upload the videos on tress and graphs

  • @saidaouyous3485
    @saidaouyous3485 3 года назад

    thank u so much

  • @chingkhei_thoudam
    @chingkhei_thoudam 2 года назад +1

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

  • @TheUniqueCoder
    @TheUniqueCoder 4 года назад +4

    Please make seris on c++

  • @user-bu8mg7uq3s
    @user-bu8mg7uq3s 3 года назад

    thank you

  • @exoticcoder5365
    @exoticcoder5365 3 года назад

    Useful

  • @cyrilemeka6987
    @cyrilemeka6987 Год назад

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

  • @KushagraSinghhh
    @KushagraSinghhh 3 года назад +3

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

  • @saikrishnathota5972
    @saikrishnathota5972 4 года назад +1

    Please upload network theory classes sir

  • @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

  • @indian3451
    @indian3451 4 года назад +4

    please do on Dynamic Memory Allocation

    • @anonemoose102
      @anonemoose102 3 года назад +1

      like how your name's jus indian lol

  • @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?

  • @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 :)

  • @undercrackers56
    @undercrackers56 4 месяца назад

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

  • @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

  • @dhaneshprabhu72
    @dhaneshprabhu72 2 года назад

    Can union have a struct as it's member

  • @amwamique
    @amwamique 10 месяцев назад

    Arrow operator is also known as Reference operator.

  • @trilecao9014
    @trilecao9014 3 года назад

    Thanks 0:22

  • @bhaweshkathayat7033
    @bhaweshkathayat7033 Год назад

    Sir please bring a web development course

  • @shubhamkandekar4723
    @shubhamkandekar4723 2 года назад

    can a pointer be a union member?

  • @harshrana2004
    @harshrana2004 4 года назад

    Voice!

  • @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 🤣🤣🤣🤣

  • @hacxngrafit4323
    @hacxngrafit4323 Год назад +4

    Too much efforts

  • @SportsGyan_
    @SportsGyan_ 3 года назад

    no its showing of different memory...

  • @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 3 года назад +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 Год назад +8

      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...!!!