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