‫Hello and welcome, everybody, and in this lecture, we're going to implement Prince F, so just go
‫to a Studio C and if we open up Firefox, you will see the print F function prototype.
‫Right?
‫Just copy and paste it into here because this is what print F should look like otherwise.
‫Just right, right.
‫Where you see it's not so bad.
‫These three dots at the end are very important.
‫It means our C function can have an infinite number of arguments.
‫OK, just by here I want you to include HDR dot org that'll give us access to the VA, which will allow
‫us to access the arguments they've passed to us.
‫So let's create a V list.
‫We're going to create two pointer variables.
‫We're going to create a integer variable.
‫Now we're going to go Vuh, start AP, FMT, or I suppose you could use format actually let's rename
‫this to format FMT.
‫I mean, we named format to format is a bit bit easier to read and we're going to go for P equals FMV
‫asterisk p p plus plus.
‫So what we're saying here is while there's no null Terminator on processing and I were going to say
‫if Crispi does not equal percent, then this must just be a character in which case we just go put Charr
‫asterisk P and then we continue because if there's no percent correct, then we're not ready to print
‫an integer or a string or something like that.
‫So what we now do is we create a switch so we go switch plus plus P so askaris plus plus P and they'll
‫take us to the next character.
‫OK, and if that's an AI, then they've essentially passed us percent.
‫I like that.
‫OK, so we need to print an integer.
‫So we just go break.
‫I vow equals via AP in it, so that reads the next argument available to us as an integer.
‫That's what that does.
‫So then we go print I Towa, I vow.
‫Now remember, we made that function recently, so we need to include that head of file now.
‫So you just include as Lib Dot Hage.
‫So we're now going to go casis, which means we're printing out a string.
‫OK, so we're going to go.
‫Especially because via AP Char.
‫Print asphalt, and now we're going to go to.
‫Pucher percent pay.
‫Break.
‫And now just to the bottom here, just go, Vanda.
‫AP analysis and the VA list, OK, so let's just right click format document, so the VA list allows
‫us to access all the arguments passed to us in this Pranav function.
‫OK, pass the dot, dot, dot.
‫So when we go vagg that in it, that gives us the first variable in the dot dot dot.
‫When we do that again, it gives us the second when we do it again, third and so on.
‫OK guys, so just read this code carefully.
‫It's very clear what's going on.
‫We're looping through the entire character array and if if we don't see a percent sign, then we know
‫to just output a character.
‫So we do percha when we finally see a percent saying we're in this switch statement, OK, and then
‫we we see which value they're trying to print.
‫Currently we only support outputting integers and strings.
‫OK, so that's what's going on there.
‫So I just want to copy and paste this and we're going to put it in a studio, just paste it in like
‫that.
‫OK, and now go to the makefile here and firstly actually go to the makefile in the kernel and scroll
‫up, because I just want to take these flags and copy and paste them into our program, OK?
‫Because we want to ensure there's no standard library compiled with us.
‫It could bring problems for us later on.
‫If we don't do that, depending on the compiler using.
‫I guess.
‫So go to the makefile of Blank Tazi, and I just want you to paste those in here, OK?
‫Just like that.
‫OK.
‫And yeah, everything should look fine now, once you've done that, just paste them into the flags
‫essentially, guys, OK?
‫And I'll go to the makefile of AEG Live and we're going to do the same.
‫We're going to just paste that in here.
‫So once you've pasted that in there for the standard library, I want you to remove Free-standing here,
‫because this is where comparing this to relocatable file, OK?
‫And I want us to go to a studio C, and there's one more thing I want us to do, just separate these
‫variables, because I just remembered that FMT is KONCZ, whereas here Chope is just a normal char.
‫So separate these and this will be a char, but this will be a.
‫And don't forget to remove that final Lascaris there guys should only be one askaris here and we want
‫to return zero at the bottom here as well.
‫OK, so just open the terminal and we're going to go make clean build that S.H. and we can see that
‫Kampala's perfectly fine.
‫OK, so let's just test printf if we're going to go into Blanchot C.
‫And we're going to go print F, uh, my age is
‫Pesenti new line, and we'll just put it ninety eight here or whatever you want, whatever you want
‫your age to be.
‫And if we know, recompile that belt.
‫And we run kumu.
‫We see my age is 98, so we've successfully implemented Prince.
‫Congratulations, what a fantastic function to have in your colonel.
‫You're now a while your operating system, I should say, use the programs, are now able to print out
‫formatted strings.
‫Amazing.
‫Thanks for watching.
‫And stay tuned to the next lecture.