Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All right.
So first of all, just before we move on, OK, I want you to go here, OK, and go to the project.
Where it resides.
OK, so you get this nice information about your project.
So here I have created a file called my file.
And I've placed here some information like, Hi, this is Vlad, how are you doing on my al-Fatah course?
OK, and saved these file as these OK, so I know that there is a file called my file that DSD with
some information inside of it.
And these file will be mainly used for comparing and testing out whether the program I have written
works fine or not.
OK, so let's close it and start working on whatever we need to do in this exercise to solve it correctly.
So we are going to read a couple of things.
We are going to read a certain character and we are also going to read the file name itself.
Basically, that's all that we need to do.
OK?
We assume that the file is going to reside in the same workspace, right?
That's why we do not need to specify the full path to the file.
And we will basically it will be enough.
We're working just with the file name itself.
OK.
So first of all, let's create char desired character.
OK, so desire character will be the actual character that we want to calculate and to see how many
times this character appears in a certain file, like the file that we've just seen.
Also, what we've got we are going to see is to create some, let's say, array of characters.
Let's say of size.
I don't know.
20.
And we will initialize it with zeros just to make sure that the last year there will be is zero value
if we exceed the actual size of the file name itself.
OK, so we created two variables are two one variable.
These are character and also an array of characters.
And what we are going to do now is simply say the following thing print.
All its use.
I don't know, please or answer these, I desired a desired character.
So the user is going to specify a character and we are going to read this character.
One of the options, look, I'm not going to go into it because it's not very important for now, OK?
The best way to do that, but we are going to do it with a simple scan of percentage.
See to read a character.
And also, we are going to ask the user, enter a file name you want to test, OK?
Now we are going to read the actual file name from the user, and we are going to read it using the
percentage ask and store it, where where should we store it inside a file name itself?
OK, so.
We have read the information and store it in the file name, so now file name, we assume that it will
have the proper file name of some file that already exists.
Right?
Awesome.
So now what we need to do once we created it, we need to open the file itself.
And if we want to open the file, we need probably to create these file pointer RFP.
OK, a pointer to these file structure, right?
And the way we open up a file is by using the FP.
Equals to what?
Two, if open.
Of what?
Of the file name itself.
Right.
Because the file name is basically a string containing the actual file name that we are interested in
and we are going to open it for reading mode.
Right.
We are going also to ask if B does not equal to now, OK, just to make sure that the file was opened
correctly, then what we are going to do is say what we need to do.
Basically, guys, what do you think we need, first of all, to go over each and any one of the characters
inside of this file?
Right.
So if that's our file, where is it?
If that's our file, we need to read this character, read these character or these character and so
on and so forth.
Until right, we reach the end of the file.
So on every kind of reading operation, we are going to read one character after the other and comparing
it with the desire or character.
And if the result is true, if they are the same, then we will need to count this.
So for that, we need to create additional variable in college.
I don't know counts.
Let's go count to appearances equals to zero.
OK, so far so good.
Awesome.
So if we said that we are going to read the file until we come to it and so if file and a file.
For FBI, then what we need to do is ask a simple question if.
F get C right, because we need to read from file one character, FBI.
If it equals two, what do the desire and character, then we simply do.
Count appearances, count appearances plus plus.
That's it.
So we are going to go over each of the characters under the file that we opened using the FP pointer
and then to increment every time count appearances.
Plus plus, if we found that these certain character that we read equals to the desire or the character
that we are looking for.
OK.
Finally, what we are going to do inside of these program is to use the printer function and say the
following like total appearances appearances of character, of which character of character percentage
C. Let's say it will be percentage and we will specify the desired character here and the count appearances
right here.
All right.
So that's basically what we are going to do.
Now, what I suggest is let's test these function and these program, basically.
Okay, so that's all of the program that we developed.
Now let's test that and see how it works.
OK, so let's say we have these file, right?
This is my file, and I can see that I have a capital v Vlad just once inside of these files.
So let's test and see if this program works pretty much as we expect it to.
OK, so it's run it and we have a problem, of course.
How can it be without problems?
Let's try to figure out what happens on initialized.
Who is in on a useless Conniff percentage rate?
So here we use the ampersand, the specified the address.
OK.
Here in the file name, we do not use of the ampersand, since we already know that file name itself
represents the address of the first element inside of this array of characters.
So now we run this program and we are going to see enter a desired character and these character will
be Capital V.
Press Enter and now enter a file name you want to test.
So the file name was my.
My file, my file.
Right.
Let's check it out.
So total appearances of character vs one, which is exactly as we thought.
And let's try to run this program and see how it works with, let's say, character I presenters.
So my file Dottie XD, oh, so total appearances of character I equals two four.
Let's make sure that it actually the case.
So we have one.
We have two, three and four.
Let's make sure that there are no others.
Awesome.
So four characters for I.
And I think basically that you got the idea of how this program works.
Hopefully, it works also on your side as well.
And yeah, this is the end of these video.
And guys, please feel free to use it however you like.
Also, if you makes a little bit and you try to, first of all, get the file name itself.
So if you're using the basic scanning function, make sure that you use your space before the percentage.
See, because if you do it like this, then whenever you're probably going to hit, enter on the file
name itself.
First of all, you're going to see my file that the press enter.
So my file that will be stored in file name, but there are high chances that the anther character that
you press will be stored in the desired character and not the actual value that you want to read afterwards.
Okay, so that's very important to bear this in mind.
So if you're doing it like this, make sure you do it this way.
OK.
So, yeah, think you guys tested out on your own rights on file?
Make sure that it works correctly if you have any questions suggestions.
I don't know some dilemma that you want to ask and share.
Feel free to do that.
That's what we are doing here and that's why we are here.
We are all here to study, to improve and to become better programmers and better developers.
Oh, that's it.
So my name is lad, this is Alpha Deck, and I will see you in the next videos.
Bye bye.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.