WEBVTT

00:00.830 --> 00:08.310
In this lecture I want to go over some simple input so we can start making some more interesting programs.

00:08.780 --> 00:16.870
An input will come up again and again but for now we're going to keep this very simple so we can just

00:17.220 --> 00:21.330
we just have something easy for us to to work with for now.

00:21.950 --> 00:29.520
So we've already seen how to output something to the console.

00:29.740 --> 00:32.200
And we did this using C out.

00:32.770 --> 00:38.020
And what is called the extraction operator.

00:38.070 --> 00:48.880
So this is the three here these two arrows are the extraction operator and we can chain them together

00:48.910 --> 00:49.690
like this

00:52.770 --> 00:57.640
so your I-ness say hello everybody.

00:57.640 --> 00:58.340
Right.

00:58.810 --> 01:13.620
So this sea out has this extraction operator and the way I remember it is the text here.

01:13.630 --> 01:14.660
Hello everybody.

01:14.980 --> 01:25.360
And the Endal will sort of funnel into sea out so the arrows kind of show where the data is going in

01:25.360 --> 01:26.680
the sense.

01:26.680 --> 01:34.240
So if we have something called Sea Ouch you'd still stand to reason that we'd have something called

01:34.240 --> 01:36.310
Sea in.

01:36.440 --> 01:46.070
So if out is the output to the console in would be in from the console and if you think that you would

01:46.070 --> 01:47.430
be right here.

01:47.750 --> 01:49.860
In fact you're exactly right.

01:50.060 --> 01:58.670
There is something called Sea in and let's try an example of how to get some input from the console.

01:58.670 --> 02:07.690
So we have char char input and let's just say Please enter character

02:10.780 --> 02:12.090
this.

02:12.580 --> 02:13.200
The Endal

02:16.020 --> 02:25.160
will say seen and noticed how this operator which is called the extraction operator is the opposite

02:25.190 --> 02:33.190
of the sea out insertion operator see char input.

02:33.190 --> 02:48.700
CH So again how I remember it is c in will put things into and there's little arrows into this.

02:48.710 --> 02:57.750
In this case this char variable and the opposite for sea out say see Ouch.

02:58.410 --> 02:59.350
Character

03:01.500 --> 03:04.220
inputted is

03:07.730 --> 03:09.020
share in

03:12.010 --> 03:16.170
so let's see what happens if you're in this.

03:16.360 --> 03:22.550
So please insert character and notice how it's waiting.

03:22.700 --> 03:31.260
It doesn't just do this line 16 and line 17 and line 19.

03:31.390 --> 03:37.250
It's actually waiting on line 17 right now for you to actually input something.

03:37.300 --> 03:50.690
So as input he and you press enter and then it'll it'll actually stop blocking on inputs and go to the

03:50.690 --> 03:52.330
next line.

03:52.990 --> 03:55.470
So this is very important.

03:56.510 --> 04:02.090
This is a very important concept that will matter a lot later on.

04:02.600 --> 04:08.630
So I put in e and it outputted that I inputted.

04:08.810 --> 04:13.440
So let's run that again just to make sure we're not it's not crazy.

04:13.520 --> 04:19.440
Say a W and character you input is a W.

04:20.050 --> 04:26.990
So just to show that it doesn't just work on char's Let's put like an integer here.

04:27.060 --> 04:38.470
It's called input.

04:38.640 --> 04:39.290
Put ch

04:44.150 --> 04:59.510
in say Please enter a number number and the number you see number 10 and the number you inputted is

04:59.520 --> 05:00.190
10.

05:00.260 --> 05:01.040
So it works.

05:01.060 --> 05:05.220
So cnt both see an NCO work on different types.

05:05.280 --> 05:06.800
I can even have a float

05:09.130 --> 05:12.070
in to see if input

05:18.250 --> 05:30.700
this in again or favorite number one for and it's three point one for.

05:30.720 --> 05:38.600
So just like the distraction operator for C Ouch which could Schene multiple things together a line

05:38.610 --> 05:56.390
20 year we're chaining this tax rate here class the input plus the Endal and also chain multiple input

05:56.420 --> 06:13.540
see either say if input to these Enter say two numbers and I'm going to say with space tween and I'm

06:13.680 --> 06:16.390
going to change to the next one.

06:16.470 --> 06:29.570
So if input to output here so you know say the first number you inputted and then out.

06:29.640 --> 06:37.040
CH The second number put in.

06:37.460 --> 06:41.960
If that's the word that's used for now.

06:42.070 --> 06:47.620
Input to Andell.

06:47.750 --> 06:49.110
Let's run that.

06:56.350 --> 06:56.960
Going.

06:56.990 --> 06:58.410
Always have the semi-colon.

06:58.440 --> 07:02.730
Very important as compiler will complain to you.

07:03.130 --> 07:12.470
So let's say three point one for in 6 3 9.

07:12.470 --> 07:13.220
Sure.

07:13.330 --> 07:22.150
And I notice there's a space in between you enter so and that puts exactly what we thought.

07:22.160 --> 07:26.550
First one is Threepio and for the next one is six point eight.

07:26.740 --> 07:35.300
The reason why we need to have the space in between is c in this extraction operator actually ignores

07:35.810 --> 07:44.550
whitespace so a space would be a white space to be tambour the space bar or return line.

07:44.720 --> 07:46.480
Something like this.

07:46.520 --> 07:54.100
So let's run this again and say let's give it a bunch of space and then we'll enter three.

07:54.200 --> 08:00.530
Another bunch of space and 23 and maybe more space after.

08:00.550 --> 08:06.370
So still it just ignores the whole thing and then reads the float.

08:06.370 --> 08:07.470
In this case.

08:07.720 --> 08:15.350
And then again ignores all of the whitespace and then reads the next number 23 and outputs.

08:16.380 --> 08:27.750
So just remember that the extraction operator is what ignores all the whitespace not see it.

08:28.490 --> 08:38.440
So this is enough to get started for some simple programs that we're going to be working on in the next

08:38.440 --> 08:39.500
few lectures.
