All language subtitles for 2. Challenge 2 - Implementing strcpy

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

All right, welcome back, ladies and gentlemen, and in this video, what we are going to do is we

are going to implement all by ourselves the function that we all have been using and talking about,

which is actually actually these function is a part of this string that each library and this function

is none other than the RCP y.

And as you can remember, that Evy's function, all it does is simply receives one, let's say, one

place in memory where we are going to copy a string from another place in memory.

So it was something like char pointer is the destination destination.

And also it received a string location where we want to copy from.

Okay, so it's the RCR.

It's the source is actually the source string that we wanted to copy to as to our destination place

in memory.

And we've seen also how we can use it basically by including this string that H and how we can use these

as the RCP y for our needs.

And also we talked about what are the limitations of the RCP, why, how it should be used, when it

should be used, and basically what we should kind of avoid while using it.

And in this video, what we are going to do is that we are going to say, all right, we know that these

string that H includes the SDR recipe Y.

So what we are going to do is simply to delete it and think about, OK, we didn't have this library

yet and what we want to do is to develop these function.

OK, let's leave it this way is to develop these function all by ourselves, basically implementing

these function in one way that it will work.

Exactly.

Or pretty much as it has been working in the string that age.

And the reason for doing so is very simple because we want to improve our programming skills and we

also want to learn how we can create functions that are similar to other functions.

Of course, if you just need to like to run your program, that's OK.

But a lot of times features and also interviewers, they will ask you, OK, so you're using these as

the recipe y function.

But do you can you can you tell me the logic behind it?

Can you tell me why these function runs as it's, as you say, runs and in this place in time you have

to start thinking about, oh, wait a second, what really is going on behind the scenes and what is

really happening in this function?

And one of the ways to do so is to practice, then to write the implementations kind of from scratch

like we are doing right now.

Awesome.

So let's let's begin.

And first of all, what I want us to do is to like, you know, like create our of our main function.

And here we will use, I don't know, some strange let's make it my name.

OK, so my name and we will use here.

Let's use it now.

Let's use my nickname, my nickname.

OK, my nickname will use here or something like that.

Alphatech OK, so we will use Alphatech as our input string is our source string and also we will create

some destination's trend which will be like, like let's say a copy of nickname.

OK, copy of McNee.

Anything will be let's give it some size, I don't know, like 30 characters just to make sure that

we have enough space to make this copy.

All right.

And now what do we want to do is to say that we will use the CPA function.

One way to do so is the RCP y.

OK, so for some reason it remembers previously that we have been using it, but we will use here of

the destination.

OK, so copy of nickname and also we will use here the source right at the source.

So my nickname.

So basically these function is not defined yet.

It's not declared.

Well we know nothing about.

If we will try to build and run it, probably you will not be able to use it unless it is part of the

Dileep.

No, I don't think so.

It was part of the string.

That age probably only remembers the signature because I just removed the include string that H.

So either way, what we are going to do is to write this function down.

So let's start in.

The first thing that we have to do is to first of all, right.

Of a function signature and what should be the function signature.

Basically, it also can be of every type, because we can see here that the function does not return

anything, but also we may say that we would expect to use this function in kind of like, you know,

like this wasso copy of nickname will be equal, like something like a starship.

You why if this copy of a nickname was a pointer, a dynamically a dynamic pointer or something like

that.

So for example, if you had here or something like let's say temp result, temp result and inside of

temp result, you would use it like that as a temp result equals to WDR, if you like, kind of to make

sure that the RCP y also returns returns of the exact address of where the string was copied to.

OK, so what we are going to do is to say, OK, if we want to make sure that the function returns,

the address of the destination string of where it has been copied to.

So what we are going to do is to write the type as a star.

Right, because we want to return the address of the first character in the string.

And we are going to say that the type are the name of the function will be as the RCP y.

OK, awesome.

Now we are going to use our star destination and our star source.

OK, awesome.

So what do we want to do now is that first of all, you can also make sure that there is enough memory

in the destination and you can, I don't know, kind of run some loop to make sure that the destination

addresses that you can access is actually more in memory than the source.

Because you remember, the first rule that we spoke about is the RCP.

Why is that the destination?

It's kind of our duty as the developers to make sure that there is enough memory to copy to.

Right.

So the source is 10 bytes.

So there will be at least 10 bytes at the destination.

So you also make add these are check here.

So that's also OK.

And what I'm going to do is to like, let's say to create additional variable and this additional variable

will point.

All right.

It will point to the address, the the first element of the destination.

So let's call it temp.

Let's call it temp BTR.

OK, so Tempa and we will say that tempters will be pointing to the destination destination.

Awesome.

And now what we are going to do is that we know that the source is a string.

Right?

He's pointing to a string and we know that every string ends with a backslash zero.

So what we are going to do is that we are going to run some loop.

OK, so let's create additional variable that will help us with that.

So ENTI equals to zero.

OK.

And we are going to run as following.

So just to make it as much easier for you as it can be.

So while saurus OK source at the index of AI.

All right.

While Source said the index of AI does not equal to does not equal to backslash zero.

Right.

Meaning we didn't get until we didn't get.

Let's wait till we got to the end of the source string.

OK, so until this happens then we can say that destination in the index I will be equals to source

of the index.

I simply copying bite by bite meaning character by character are from source to destination.

And that's what we are going to do also is to increment I by one.

So I.

Plus plus.

All right.

So then either.

There you go.

You copied everything.

OK, so everything from the source was copied.

And also you could you could have make sure beforehand that something like that.

OK, I will not write it as part of our program, but if it's are land of let's say saurus is greater

than and find the length of the destination, if you can find it, then return or print some problem

or something like that, that's also an option.

But I will not add it here.

Just just that you will know that there are additional conditions in some conditions that you may add

to like, you know, like to extend the functionality of these given function.

OK, and now what we are going to do is that we copied everything from the source, all the characters

from the source to the destination.

And one character that we did not copy is the backslash zero at the end.

OK, so we we run this loop until we reach a backslash zero.

So meaning this nation does not have as the last character of the Bixler zero, which is exactly what

we do not want, we want the destination's to be like to be pounded with these backslidden zero at the

end, that it will specify that all of the characters coming before it, they are part of the destination

string.

So what we are going to do is that we are going to write destination at the index of AI, OK, because

we know that I was incremented here one after the other and I will be at the index where a source has

the backslash zero now.

So destination and the index of AI equals to backslash is zero awesome.

And basically we are almost done at this step of a destination.

Already have copied all it already has copied all the characters from source and now all that remains

is simply too.

Like if it was of a void type, if this was like void ECPA, then we basically were done with this function.

But we know that each would also return the address of the destination.

So what we are going to do is return, return Tambe BTR or basically there is actually no real reason

to as a way to do so.

It just wanted to show you how to separate them.

Stampeder points to the address of the destination, so meaning you could have just also returned the

destination.

Right?

There is no reason why not.

At least I can see.

I cannot see it right now.

So there you go.

You've implemented these function.

And now what we are going to do is to print the results or print the let's say the new copy, the string

A's and percentage s here backslash and at the end.

And here, instead of the percentages, we are going to use temp result, for example.

OK, so temp result and also we can use just to make sure that everything work is expected.

Copy of nickname.

OK, so then you copied string and then you copied string on basically both of them are simply pointing

to the same address just by different names.

OK, so let's try to build and run it.

So you go here, build and run and there you go.

You can see that the new copied string is Alphatech and the new copied string is also Alphatech.

And basically, I think, guys, that you're starting at this point to feel like you're more practiced.

Basically, you implement you have implemented your own way.

The the yes.

The RCP y function that has been used by the string library string that h that we've seen in one of

our previous videos and was developed by somebody else.

Actually, I think OK, as a matter of fact, that you should be proud of yourself.

So thank you guys for watching.

Keep on practicing, write some notes down, try to write this function on your own, on your free time,

and let's proceed with more exercises and more knowledge and becoming better programmers until next

time.

I'll see you there.

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