All language subtitles for 2. Arrays - Copying an Array - Solution

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
hu Hungarian Download
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 let's understand how we can copy an array.

So, first of all, we said that we need to initialize it with some values in the array is going to

be of a size three, OK, because we represent a date and we know that it eight consists of day, month

and year.

So that's why we are going to use the size of three.

And now what I want us to do is to initialize this array.

So let's say we are going to call this array are indeed.

OK, so in date will create, let's say, of cise right this size.

So this way we declare an array of size three in this case sizes three.

The name of this area is going to be date.

And at every sale, at every element of this array, we will have an integer value.

But we said that we don't want just to declare it.

We said that we want to initialize it with some arbitrary value.

So let's say one is the date is the day, two is the month and two thousand is the year.

OK, so we initialized our array and now what do we want to do is to create additional arrays.

So let's say into today two of the same size.

We just created not two, not only initializing it, just creating it.

And we want to copy we want to copy this array, the original array do these particular array, which

is on initialized in this step.

So what will be the most intuitive way to do so?

So we are probably right, because the most easiest way that would come to mind is simply to use the

assignment operation and just say day two equals today and that's it.

You're done.

And you expect that this array will just be copied into these data.

But that's not the case.

It won't work in our programming language.

So for for copying an array, for copying one array into another, we are going to use some for a loop

to basically these for a loop will allow us to run over each of these elements and to copy them one

by one into these secondary our target array.

So for that, we need to create additional variable int I that will help us in using the for loop and

now we are going to use for equals to zero as long as I list this size I plus plus and now in the loop

buddy, we are going to copy the elements one by one.

So previously we have declared this array.

So behind the scenes.

OK, so we has three elements and there is some garbage values let's say are stored inside here.

And we are going to iterate over this array.

And first of all, IT index equals to zero, which will give us the value of one we are going to copy.

So just use data and the indexing will be equals to date at the index.

So copying element by element one after another.

That's how you copy an array in C programming language.

Now once you've copied, let's try to print the content of each of these arrays so it equals zero eyes

list then size II plus plus.

OK, so now we are going to print the values to print the elements inside of these of any of these arrays.

So print f let's do it like this or print f r r let's see date original date original or Reiji original

date and index the original date m original date.

They know how we should do it, how we should do it.

We should simply use some index.

So let's say we are using original date at index, let's say percentage equals two percentage D and

and here we are also going to use additional print earth line.

So will we will see the target.

OK, or that copied, copied, copied date at index percentages equals the percentage.

And here instead of these percentages of the first one, we are going to specify are I right, which

is the index.

And here the value itself of the original date, which will be just date at the index I and here we

are going to use pretty much the same.

So I and just date to the date of the copy date index.

OK, so what will be more correct probably is that we initiate or at first will just would have just

created, created this array is the original date, will just name it original date and copy date.

But we are already done with this exercise if we are going to run this program now.

So build and run it, you're going.

To see that original data, the index zero equals to one and also the copy dead, and also you can see

the same values for each of these indexes.

So this is how you copy an array.

You don't use just the assignment operation like these, like data equals to date because that won't

work.

It probably won't even run to you guys.

And my guess.

Yeah, this is it for this video.

Now you know how the copy how you can copy an array and it may be an array of integers, an array of

floating points, an array of charges and so on.

This is how you copy arrays.

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