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
I like how you explain straight to the point. No time wastage :) Less time searching and more time learning. Keep up the good work
Thank you sir, can you please upload presentations about :
-linked lists
-trees
-graphs
Thank you, this made it so much clearer than anything else I’ve seen!😄
Excellent explanation sir....keep doing it sir...it would b really helpful to many of the students..👍👏😊
Thank you
Few words useful explanation
incredible explanation, good job !
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
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
Thank You Sir for such great videos.💕💖
Perfect explanation, thank you!
Excellent explanation sir ❤❤
Make more such videos on multiple choice questions...
I am learning from your videos 👍👍
No timepass ,
Only to the point , perfect lecture
Thank you sir. Recalled the concept of union in fraction of mins .
That was a really good explanation.
Thanks Man!
Thank you! You are explaining very well
thank you sir!!! you explained union very well while no one explaine like this
wow awesome sir.. seriously very nice presentation
Thanks a lot for your clear and nice presentations
Good explanation and easy to understand. Great job.
max information sharing within min tiime.👏
Just brilliant 🙏🏻🙏🏻🙏🏻
This video really helps me and lets me learn the topic
U teach soo clean and nicee😍
Very clear. thank you sir.
Your explanation is too better and simple way ❤
Very helpful video, thank you!
Thank you for this presentation 🎉🎉
perfect explanation, thank you
so clear and concise. thank you
Best Explanation!
Excelent! Thanks!
amazing! so precise :D
Perfect explanation...!!!
This is perfection!
Thanks sir your videos are really helpful for me
You won @2:00 with the kind of explanation. Great 👏👏👏👏
Sir it's marvelous
This is top notch content!
please upload videos on nested structures Sir.🙏🙏🙏🙏
Like
Straight from the text book.
Too good...
It's clear to me ❤️
Thank you so much!!
you are great so helping
Thank you sir very good explanation
Clean explaination
Best representation ever I watched..
wonderful lesson
Awesome explanation 👍
Amezing videos on c programming.... Thanxx for making such a wonderful videos...
Thanks a lot 🙏
Good explanation sir.tanq
Nice explanation
Thank you so much sir 💖💖
Thank You!
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
nice explain sir💯💯💯
Great channel
Very good video
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?
sir if the union contains only int(4bytes)and float(4bytes), which datatype size will it consider and y ??
Thank you.
Very nice sir
Thanks !
love it 🍋
Thanks 😊
Sir, please upload the videos on tress and graphs
thank u so much
Why the value of a is printed? Isn't the memory of a be overwritten by b as b executed later?
Please make seris on c++
thank you
Useful
There was nothing vague in this video. Continue the good work
Very helpful . Just a suggestion : Please attach the link for the slides also in the description box.
Please upload network theory classes sir
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.
bro if you got answer plz reply back as i also thought oh=f same thing plz reply
please do on Dynamic Memory Allocation
like how your name's jus indian lol
ok, but if we create union as an object in the heap like: abc* var = new abc() then do they share the same memory?
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 :)
Sir, I think you have set the standard on how to present computer programming topics.
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
Can union have a struct as it's member
Arrow operator is also known as Reference operator.
Thanks 0:22
Sir please bring a web development course
can a pointer be a union member?
Voice!
What if var.a = 129 ? I mean to say what will be displayed for char if no ASCII corresponding is not there...?
www.onlinegdb.com/online_c_compiler here's your answer.
@@vishallondhe7298 🤣🤣🤣🤣
Too much efforts
no its showing of different memory...
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
I thought this was C tutorial not C++.
Like we are deaf, why say same thing thrice written on the slide? -_- 0:00 to 0:34
Overall nice video, Kudos🤘
Bruv, not everyone got the qucik grasping technique. Each time he says it, he stresses it and hence people get to know the keywords.
you have a milion subs? hooly shit
It's me 1st view and 1st comment
Nope
Gg
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!
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
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
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.....
They do it for people like you and your fellow countrymen who struggle to understand C lang.
@@akshayjadhav75 I assume you learned by yourself. Just opening code blocks, and started writing stuff, and just understood it right?
Perfect explanation...!!!