All language subtitles for 3. String Initialization

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,450 --> 00:00:07,800 So in the previous video, we've defined water swings and we talked about how to declare them as well 2 00:00:07,800 --> 00:00:14,370 as we also said that strings are simply arrays of characters with a now suffix. 3 00:00:14,520 --> 00:00:20,070 And in this video, we are going to talk about how can we initialize strings? 4 00:00:20,400 --> 00:00:23,910 So basically, there are a couple of ways to do that. 5 00:00:24,300 --> 00:00:29,760 And in some of them, there is a critical difference, which we will talk later on in this course. 6 00:00:29,930 --> 00:00:34,710 But for now, let us see how we can initialize a simple array of characters. 7 00:00:35,010 --> 00:00:38,880 Another string, but a simple array of characters. 8 00:00:39,390 --> 00:00:43,890 So basically, we know how we can initialize a an array of characters. 9 00:00:43,980 --> 00:00:44,250 Right. 10 00:00:44,280 --> 00:00:47,640 We just specify the type of of this array. 11 00:00:48,030 --> 00:00:49,710 The name square brackets. 12 00:00:49,710 --> 00:00:55,680 And then in the curly brackets, we specify each of the elements, each of the characters in this given 13 00:00:55,770 --> 00:00:56,190 array. 14 00:00:56,730 --> 00:00:58,950 So these arrays called Chass Array. 15 00:00:58,980 --> 00:01:00,000 That's its name. 16 00:01:00,030 --> 00:01:01,770 And that's Matus Thring. 17 00:01:01,950 --> 00:01:09,420 That's just an array of characters with five elements starting from index zero up to index four. 18 00:01:09,540 --> 00:01:10,560 So that's okay. 19 00:01:10,590 --> 00:01:12,000 And everything is great. 20 00:01:12,150 --> 00:01:14,250 But how should you initialize a string? 21 00:01:14,490 --> 00:01:22,080 Simply saying we just need to add a null character, a backslash zero character to the end of this array. 22 00:01:22,500 --> 00:01:28,430 So one of the ways to do so, the first option to do so would be just like we've done with the characters 23 00:01:28,440 --> 00:01:28,760 array. 24 00:01:28,800 --> 00:01:33,180 So simply kind of initialize a character's array. 25 00:01:33,270 --> 00:01:33,570 Right. 26 00:01:33,810 --> 00:01:34,910 Char etr. 27 00:01:35,220 --> 00:01:39,180 And just using the curly brackets, the hollow letters. 28 00:01:39,330 --> 00:01:44,970 And then since it's a string, don't forget to add that now character to the end. 29 00:01:45,090 --> 00:01:51,740 And now from this point on the computer will know that it can treat test ya as they string, meaning 30 00:01:51,750 --> 00:01:57,680 you will be able to use different new operations and functionalities on this given string. 31 00:01:57,840 --> 00:02:02,940 That basically a lot of these functionalities we are going to learn in this chapter. 32 00:02:03,350 --> 00:02:03,590 OK. 33 00:02:03,680 --> 00:02:10,020 So in one of the following videos, we are going to talk about different functionalities that we can 34 00:02:10,020 --> 00:02:13,590 do with strings and some built-In functions and so on. 35 00:02:13,770 --> 00:02:14,770 So just wait. 36 00:02:14,790 --> 00:02:17,820 Guys, there is a lot of things to cover up in this section. 37 00:02:18,510 --> 00:02:19,890 And before we move on. 38 00:02:20,130 --> 00:02:20,460 Right. 39 00:02:20,560 --> 00:02:24,090 This that was the first option to initialize a string in C. 40 00:02:24,240 --> 00:02:29,040 And before we move on, I want us to take a look at another way to initialize a string. 41 00:02:29,250 --> 00:02:34,410 So the second way is kind of different from the first way that we used to initialize a string. 42 00:02:34,890 --> 00:02:37,980 And anything evolve the usage of double quotes. 43 00:02:38,040 --> 00:02:42,300 So, for example, we can initialize a string in the second way as follows. 44 00:02:42,420 --> 00:02:49,950 We simply write char, which is the type SDR in a square brackets in very similar to how we initialized 45 00:02:50,250 --> 00:02:53,970 an array of characters or the first option to initialize a string. 46 00:02:54,150 --> 00:03:01,290 And you can see that visually e it is this initialization is somewhat different from the first option. 47 00:03:01,320 --> 00:03:06,390 But behind the scenes, what is actually going on is very similar to the first way. 48 00:03:06,510 --> 00:03:13,200 This halo, which is within the double quotes, is also interpreted as a sequence of characters. 49 00:03:13,590 --> 00:03:20,160 And the novel is obviously appended to the end of it because it's a string, even if you do not see 50 00:03:20,160 --> 00:03:22,080 it in the initialization itself. 51 00:03:22,140 --> 00:03:24,240 Like we use in the second option. 52 00:03:24,600 --> 00:03:31,890 So basically the backslash zero is appended to the halo behind the scenes in the second option, like 53 00:03:31,950 --> 00:03:32,850 in the first one. 54 00:03:32,970 --> 00:03:38,730 So simply saying these two options to initialize the string are pretty much the same. 55 00:03:39,150 --> 00:03:46,200 So we can try and initialize these examples on your own, using your own idea, and then try and print 56 00:03:46,200 --> 00:03:49,140 out the contents character by character. 57 00:03:49,320 --> 00:03:51,180 You already know how to do that, right? 58 00:03:51,300 --> 00:03:57,930 So parse the video, initialize your strings and try to print out the content, one character after 59 00:03:57,930 --> 00:03:58,470 the other. 60 00:03:58,920 --> 00:04:00,780 And basically, you know how to do it. 61 00:04:00,790 --> 00:04:02,650 Just use some while loop. 62 00:04:02,670 --> 00:04:09,570 And as long as you didn't come to the backslash zero two the now it specifies the end of the string. 63 00:04:10,050 --> 00:04:12,330 Just print one character at a time. 64 00:04:12,450 --> 00:04:13,150 All right. 65 00:04:13,170 --> 00:04:17,790 And once you're back, I really hope that you pause the video and try it on your own. 66 00:04:18,330 --> 00:04:21,300 Now, let's take a look at a couple of other examples. 67 00:04:22,050 --> 00:04:27,570 So let's, first of all, create a string for the first name and initialize it with our first name. 68 00:04:27,870 --> 00:04:32,420 So in my case, my first name is Vlad, and that's how I created. 69 00:04:32,610 --> 00:04:39,330 So in this way, you initialize your first name string that looks like this in the memory of your computer. 70 00:04:39,450 --> 00:04:46,080 Just the letter, the characteris V L a D and a suffix of null at the end of the string. 71 00:04:46,290 --> 00:04:49,650 And now let's say that you want to initialize your last name. 72 00:04:50,170 --> 00:04:53,430 In my case, that's going to be a really long one. 73 00:04:54,600 --> 00:04:57,060 My name is Vlad Bood Need Scheme. 74 00:04:57,270 --> 00:04:59,840 So the way I initialize my last name is. 75 00:04:59,940 --> 00:05:05,370 Sea land, which will be like that char, last name of of size 10. 76 00:05:05,530 --> 00:05:08,900 And my last name, which is both need ski. 77 00:05:09,070 --> 00:05:12,910 And the last name is said to be of size down for a reason. 78 00:05:13,510 --> 00:05:17,200 We have the first nine characters which represent my last name. 79 00:05:17,410 --> 00:05:20,990 And also we have to hold some space for the additional. 80 00:05:21,100 --> 00:05:24,670 And of Thring indicator, the backslash zero, the null character. 81 00:05:25,000 --> 00:05:29,120 So I hope that's clear why we have 10 characters instead of just the nine. 82 00:05:29,140 --> 00:05:29,320 Right? 83 00:05:29,380 --> 00:05:35,080 Because we are using strings and we need a space for the last now character. 84 00:05:35,200 --> 00:05:40,840 And lastly, let's say that you also want to initialize a string that will hold your password. 85 00:05:41,020 --> 00:05:45,050 So that will look something like this char password sized down. 86 00:05:45,550 --> 00:05:52,300 And let's say that your not so you don't have so sophisticated password, which is one, two, three, 87 00:05:52,300 --> 00:05:53,620 four, five, six, seven, eight, nine. 88 00:05:54,190 --> 00:06:00,520 And by the way, I do not recommend you using these types of password because they are easily hacked. 89 00:06:00,860 --> 00:06:01,360 So. 90 00:06:01,710 --> 00:06:08,320 So now if we take a closer look and look at these password Thring, it's kind of strange. 91 00:06:08,320 --> 00:06:09,490 It's kind of new, right. 92 00:06:09,490 --> 00:06:17,620 Because we are using a number as a string and basically saying there is no problem because we can also 93 00:06:17,620 --> 00:06:19,600 store a string of digits. 94 00:06:19,630 --> 00:06:23,350 Digits also may be represented as characters. 95 00:06:23,470 --> 00:06:24,450 So that's okay. 96 00:06:24,490 --> 00:06:31,510 And what we've created here is a string with nine characters, and the last one is a null character, 97 00:06:31,540 --> 00:06:31,840 right. 98 00:06:31,870 --> 00:06:35,360 As every string in our C programming language. 99 00:06:35,890 --> 00:06:41,290 And we can access any of these digits just by specifying the index itself. 100 00:06:41,350 --> 00:06:42,790 And there you go. 101 00:06:42,820 --> 00:06:47,200 There you have your password represented as a string. 102 00:06:47,320 --> 00:06:50,050 And why do you want to store your password? 103 00:06:50,060 --> 00:06:50,740 There's a string. 104 00:06:50,770 --> 00:06:57,400 So one reason for that is because passwords may be may be just with numbers. 105 00:06:57,430 --> 00:07:02,500 But most of the passwords include the combination between letters. 106 00:07:02,650 --> 00:07:02,980 All right. 107 00:07:03,010 --> 00:07:06,160 So ABC and then you go one, two, three and so on. 108 00:07:06,400 --> 00:07:11,020 So it may be a combination of digits and characters and so on. 109 00:07:11,050 --> 00:07:14,980 So you want to be able to store it as a string. 110 00:07:15,580 --> 00:07:17,590 So this is it for these video. 111 00:07:17,620 --> 00:07:21,300 I hope it's clear as to how you should initially strings now. 112 00:07:21,430 --> 00:07:28,030 And just last note, I want you to know is that there is also another way, additional way that we can 113 00:07:28,030 --> 00:07:31,370 initialize strings in our C programming language. 114 00:07:31,810 --> 00:07:34,300 And that can be done using pointers. 115 00:07:34,450 --> 00:07:40,450 And that's also very important to understand, because in this additional way, we are going to create 116 00:07:40,450 --> 00:07:41,170 this string. 117 00:07:41,260 --> 00:07:43,540 It's a read-only memory region. 118 00:07:44,020 --> 00:07:48,940 And this way, you want to be able to modify these streambed after it was created. 119 00:07:49,090 --> 00:07:55,930 But all of that, it's going to be discussed in the advanced courses and where we are going to see a 120 00:07:55,930 --> 00:08:02,530 lot of different topics that also include the usage of strings, pointers, the combination between 121 00:08:02,530 --> 00:08:04,840 their memory applications and so on. 122 00:08:04,960 --> 00:08:08,230 So thank you guys for watching and have a great day. 11714

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