All language subtitles for 12. Structs having arrays as data members (and copying struct variables)

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So in this video, we are going to talk about structs having a raise as data members.

OK, so we know that strikes can be simple.

Instructs may be complicated, but in these video, we are going to mix a little bit of a couple of

different data types in a simple struct.

So this struct that we are going to use in this video is basically a struct for representing an employee

at some company.

OK.

We could also use it like typedef struct student two to represent the student.

Let's simply stick with the example that we have to represent a certain employee.

OK.

So we have an employee, we have this structure.

And if we read this structure line by line, we can say that we have the first member of these employees.

Struct is an array.

Of sites then.

OK.

And also, we have float age and an integer I.D. So if I try to basically basically to to demonstrate

you visually how a variable of this structure should look like, it should be something like that.

OK, so let me draw it.

This is a variable of an employee type, and we will have something like this.

It will be IED.

It will be an age.

OK?

A floating point and integer in here.

We will have the name.

Which is an array of size 10.

OK, so basically here at the same, we will have an array.

With 10 values.

Characters, OK.

Zero, one, two, three and so on, up until nine.

So.

This structure consists of three members.

The first one is an array of characters of size 10, and it's called name.

The second one is age and it's a fly off type float.

And the third one is ID of typing.

That's it.

That's the whole structure that we created this new box.

OK, good.

So now what we are going to do is basically to look at how can we create an object of this type?

OK, so first of all, we create an object called MMP one employee one.

And these employee one, we can say, let's let's leave it as this.

OK, so that will be the employee one.

We didn't specify what should be its values.

OK, no problem.

It's just kind of empty.

We also create the second employee MP two, and we initialize it with a few values.

We specify that there is Jake and there is some values.

So there will be like J a k e zero.

Of course.

OK.

That's for the name, and that's for the age and for the ideas over the ages.

We're twenty four point five and the adds one two three.

OK, very simple.

We created MP two.

We created two variables of an employee type.

One of them we initialized with some values, while the other we did not use them to initialize anything.

OK, so far, so good.

And we are now going to see how we can use these signing operator to copy value by value.

OK?

The members of one struct variable to another struct variable, which should be of the same type.

OK, so we are going to copy all the members from impaired to.

To him, be one.

OK, we are going to copy member by member.

All right.

And.

That's something that we can do using, and B one equals two MP two.

So since we know that both of them are of the same type MP, one equals two MP, two, MP one and the

MP two are of employee one type.

So we can copy the member by member.

So afterwards there will be simply hear a value of twenty four point five.

Here will be a value of one two three and here will be your Jake.

OK, pretty much that what happens?

And just one thing that I want to specify.

OK.

That's just that you will be familiar that you can use the a sign from one struct variable to another.

OK, just copying the values, but be very careful on this one.

We will talk about some notes regarding this part.

OK?

Maybe in the next video, what will happen if we you are copying pointers that are going to dynamic

memory allocation?

Maybe, maybe, maybe.

I'm not sure that we are going this way.

But if you has to proceed with the course, he will get this material.

If not, so maybe this is not part of this section or maybe of these course.

So nevertheless, let's just basically talk also about this note that I've written here that simply

says that you remember when you had to erase, OK, let's say, to erase of integers.

We could not copy each element from every one into a redo in just one line of code.

Right.

We what we've done is we simply took some loop and iterated over all of the elements and copy them one

by one.

So a great index one equals two error two at index to its index one and copied just element by element

from erase.

But now we have strikes, although we have these arrays.

That's one of the notes that I wanted to give you in this video.

Although we have these is a race we can simply Ray Downey and P1 equals twin P2.

So it will copy it.

It will take care of it behind the scenes.

All right, awesome.

So now just to make sure that everything is copied, let's it's basically this part.

Let's go inside out and let's see that MP, one that name and empty to that name.

Both of them are identical.

Let's take a look at it so we can see that employee.

One name is Jake and also the employee.

Two name is also Jake.

Since we used these shopping.

Now the question comes, is what will happen?

OK?

Just basically to make sure that everything is copied and not and they are not kind of pointing to the

same region in memory.

So just to emphasize it, I will change some of the members in MP one.

I will change the name from Jake to John, and also I will change the ad to be instead of one to three,

to be four or five.

Six.

OK.

And this will show you that these two strikes can be one and demob two with all of its members are basically

two separated units.

OK.

Because sometimes you may have seen in different programs or something like that when you copy one thing

and you have like a copy of it and you modify the copy, then also the source is being changed.

OK, so I want to show you that it's not the case here, specifically in this example and the way we

use it.

So it's the RCP wing just copying a string John into the name P1.2 name and then changing the ad by

accessing the member I.D. inside of the variable MP one and changing the value to four or five six.

So now basically what we will have, let me get the yellow color.

What we are going to have is something like that.

Here we will have John.

And here we will have what it will have four or five.

Six.

OK, so just to make sure of it, let's run down some commands to print the results to the screen and

make sure that we see exactly what we expected.

So let's run it in hope for the best.

OK, so let's go command this poor talent.

We don't need it right now.

That's wrong.

So, employee, one name.

Here it is, is John employed to name is Jake.

Employee one is four or five six and employed to I.D. is one two three, exactly as we expected.

OK.

So in this video, we talked about this operation of assigning once tracked variables to another as

long as they are of the same type.

OK.

Don't mix it up, too.

I don't know to assign employee to some struct date.

OK.

That simply won't make any sense.

OK.

Uh, yeah.

So this is it for these video guys.

Let me know if you have any questions and keep on practicing.

Write down your notes.

Keep on moving forward and you are bound to succeed.

I'll see you next time.

Bye.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.