Hello and welcome and today the topic of discussion is NC programming will understand program
of structure in C. So prior to this we have discussed what structure is all about, how
to initialize member of structure, how to access member of structure. If you have seen
all those two videos of structure it will be very easy for you to understand this program
So what this program is about? Write a program to store information of two employees. You
are given two employee information and you have to store that information. So what information
actually are? We have included two header files, one is string.h and one is stdio.h
So we have created a struct employee having three members, one is employee, one is id
one is name, name is a character array of size 50 and one is salary, salary is of float
type. And now you have created two variables e1 and e2. The moment you create this variable
I always told you a memory will get created. So the moment you create this variable a memory
will get created. Let me make it little more bigger. So this will become easy for you to
understand. The moment you, why I am making it bigger I will make you understand. e1 and
e2, so this one is e1, this one is e2, these will have three boxes. Why three boxes? Because
there are three members. So first member is id, so it will be id. Second member is name
so this will be name. And name is a character array of size 50, so this will be of size
50, dot dot dot, size 50. And third is salary, so this will be salary. Again this will be
id, this is name, name of character array, fine, dot dot dot, 50 size. And third is salary
so this will be salary. Fine. So always try to remember this memory structure. Once you
get clear with this memory structure it will be very easy for you to understand the structures
Now store the information of first employee. So store first employee information. e1 dot
id, this is e1. e1 dot id will have value 101, so what will happen? 101 will come here
So what will actually happen? 101 will come here. String copy, we use string copy. This
is the source and this is the destination. So copy this value to, string copy will copy
e1, james to e1 dot name. So e1 dot name, james will come here, j-a-m-e-s, james will
come here. Fine. Okay, then e1 dot salary will become 56,000, so 56,000 will be the
salary. Fine. So this 56,000 will be the salary. Now I will store the second employee information
Second employee is represented by a variable e2, so e2 dot id will become 102, then we
have name, string copy, where to copy this? At e2 dot name, james bond. So I will write
james bond, I will simply write, I will not use different boxes. And e2 dot salary is
126,000. Fine. Okay. Now this is how you have initialized these memory boxes. You have filled
the memory of this variable structure. Now you are printing those values, printing the
first employee information. So what, how answer you will get? Employee1 dot id. So
you will simply like, simply like that. Employee1 id. What is e1 dot id? What is e1 dot id
101. Employee1 name colon e1 dot name. What is e1 dot name? James. You will get james
Employee1. This is employee1 space salary is what? e1 dot salary. What is e1 dot salary
56. So you will get colon 56,000. Because this is float, you will get some 000s. Similarly
you will get e2 employee2, these information. So hope you have understood the memory structure
of this, no, memory structure of this structure. Exactly the memory structure of this structure
so that it will become easy for you to understand what I'm talking about. So this was about
how this structure program is working. Fine. Now there is a drawback. Now there is a very
important drawback in this particular program. Suppose there, now you have only two employees
What if we have 15 employees? What we have if we have 20 employees? What we have if we
have 500 employees, 5000 employees? Will we keep on writing these again and 500 times
So this is such, this is, this is a kind of a stupidity. Fine. So we'll not do these
things repeatedly again and again. Instead of that, we'll create array of a structure
We'll create array of a structure. So in next video, we'll understand what array of structure
is all about. Till then, I'll say thank you so much for watching. Please like, subscribe
and share. Thank you. Thank you so much. Thank you very much