SPEAKER 1:Let's write a program that gets an integer from the user, without
using the CS50 libraries function, get int.
To do this, we're going to use a new function called scan f.
That it turns out, get int in the cs50 library users underneath the hood.
Here we go.
>> Let's first declared an int.
Let's call it arbitrarily x.
That will ultimately put the user's integer in.
Let's now prompt the user for that number, as with number, please.
And now let's call scan f, as follows.
Scan f, quote unquote percent i, indicating that what I want to get
from the user is indeed an integer.
But now I need to provide storage space for that integer.
I can't just pass in x, because recall that when you pass an argument to a
function, it's typically passed by value.
That is a copy is passed in.
So instead, I want to provide scan f with the address of x so that it can
actually change the value at that address.
To achieve that, I simply need to pass in ampersand x in order to pass in the
address of x.
>> Lastly let's go ahead and print out for the user exactly
what he or she typed.
With print t, quote unquote, thanks for the-- percent i is our
placeholder, followed by x this time, not ampersand x.
Because, as always, I want to pass into print f exactly the value that I
want printed.
>> Let's now save, compile, and run this program.
Make, scan f zero, dot slash, scan f zero, number please.
Let's provide it with o 50.
And thanks for the 50.