So, like I said, it's a special function, and since it happens first, what's really going on is
that it is actually called by the operating system of the computer.
So, you know, like Windows or Mac, you have an operating system running.
So when you run your program, the operating system is actually calling this originally.
And then from Maine, you may or may not call other functions that would be you calling other functions.
The operating system will call Maine, but in Maine, and that's where you might call other functions,
and we're not implementing these other functions yet.
But I just want to point out the difference between that.
Maine is a special function because it gets called by the operating system, and it's also the first
thing those are the things that make it special.
And so, like I say, we were going to make our own functions later.
But you just need to remember that this is the entry point of the program.
So let's move on to the first line that is getting executed that we were talking about.
So after we have our main with an open curly brace, we have stuff inside and this close curly brace
finishes off the function.
The first thing that's happening is this see out.
So what is see out what we said?
It's kind of coming from this Io stream that we included the code from, but we can't really see the
code.
So this is called a see out stream object.
And then we have these interesting little things after it.
And these are called insertion operators.
So we have some here and some here and in the middle, we have something called a string.
So between the devil quotes here we have some words and you notice before this is what printed out to
the console.
Whatever we had in between the devil course was what printed out.
And then I will get to this in line in a second, but that's another part of the line.
So what's up with the Seattle part?
Seattle is a special word that comes from this library.
I'll stream.
Which is part of that standard standard template library, it's that other file is being included.
So it lets us print text to the console, that's pretty much its purpose.
We said that it was a stream object.
So what is the stream object?
It's basically something that you can just think of as like a stream of data allows for a stream of
data to go from one place to another.
So I like to think of it as something that can let a stream of data.
Flow to the console, so whatever stream of data that you give it, it flows from here and kind of goes
into this opening right here and then you notice their arrows are kind of pointing this way.
And this is like console out.
So hello, my world is basically getting siphoned through these little like floodgates here.
And then it's going to the sea out.
So I think that's a nice analogy, the floodgates for the stream and this hello world, which I actually
have hello, my world in here is flowing through this opening out to the console, and I remember the
console as this box that we had at the bottom of our editor.
Or it was like technically in the terminal if we ran it in the terminal.
So what's this thing that's flowing through here, though, the hell of my world?
You said it was a stream, but what is the string?
A string is something that we're also going to get into later.
Just like the functions, we're going to go deeper into it.
But right now, whenever you see anything that has double quotes surrounding it, like some text in
here.
It can be numbers or a text and a combination of those and spaces or special characters or anything
that is something called a string, if it has double quotes around it and you see it in your program,
it is going to be a string and it's a type of data.
Right?
A string is a type of data.
Very, very soon we're going to get into data types and Patricia is going to go over data types with
you.
So I'm kind of just doing a very basic introduction to one of them right now, which is a string with
these double quotes.
And we'll get into that more later.
So what is this thing at the end here, so I'm not going to spend a ton of time explaining this, but
basically all it does is it just adds a new line to the output.
And what I'm going to do is I'm actually going to show you kind of what happens when we get rid of it.
So if I go here?
I pull up my console, I have hello my world.
So I go ahead and I save this and then I do a I'm on duty plus plus hello World Cup, and I'm going
to do a show and I'm just going to call it.
Hello, Dixie.
And when pressed into.
And I compile this and then I'm going to do and done slash hello, obstinate stone and slash Hello Don
easy and a prince, hello, my world like that, right?
Let's go back in here, and what I'm going to do now is I'm going to remove this in line if I remove
the in line.
I also have to remove the little floodgates, which are the insertion operator here, because that was
for the in line.
It was like the in line was flowing through this right.
So I don't need those anymore.
I actually can't have those since I deleted in line.
I now need just this pair of this output insertion operator.
So it's just going to do hell in my world.
So let's see what happens now and I get get rid of that thing that as the new line.
All right, so I'm going to compile this again, and then I'm going to run it, OK?
You notice now there's no space right here.
So when I did it before there was a there was a line and then there was basically also this extra line.
It's just nice in this.
Counsel right here in this terminal and this is command prompt, so seemed that it's just separating
these.
But if I was to go to.
Let's say Bash.
So if you're on Linux.
And I run the Hello, sexy.
You see what happens.
It just backs it up right against the prompt here, which is kind of annoying like, you know, it's
hard to read your stuff as printing and then you just have that sitting right there.
So that's why it's kind of nice to have that.
So I'm going to go ahead and add this back in.
I do an hour there and I'm going to do it.
So I have to retest this command because I'm now in bash, so I'm going to do the same thing.
And now I'm going to run it, and now you notice that it prints out kind of nicely, so this added an
extra little space for us by default.
So even though I took it away, it came out similar to what this is, but it was kind of gross here,
right?
So I went ahead and added that, and now it comes out in between these prompts so we can actually see
it better.
So that's just something I wanted to point out.
So I'm going to go back to the presentation here.
So it just adds a new line to the output.
That is what Intel does.
It comes from the same Io stream thing we included up here as well.
So now let's look at this last line right here.
So it says return zero.
So this is one of those return statements that I was talking about.
So do you remember how we talked about functions potentially returning things after they perform their
tasks?
So we have that little diagram where stuff goes in, it performs an action and stuff goes out when stuff
goes out.
That was the returning part.
So that's what this return zero is for.
Main is returning a number which is zero back and where is it returning it back to?
That's what is interesting.
So the main function was originally called by the operating system.
So when it returns zero, that's basically it saying that the program was able to finish and exit successfully.
So it's returning that as a special code, an exit code back to the operating system and that basically
says everything ran, you know, OK, we didn't have certain errors.
You know, if you have anything other than zero that signifies something else, you know, zero is kind
of this success code.
So everything else would be considered kind of an error code.
But the thing that you need to think about now is just the fact that the operating system called this
and at the end returns zero is just returning this special zero exit code back to the operating system,
and that's what it means.
And previously, I mentioned that this is not 100 percent necessary.
You don't have to put returns zero, but it is a convention.
So I'm just keeping it in here because it kind of makes sense for when we're describing a lot of these
programming things.
So and very last things definitely remember that you need to put a closing curly brace at the end of
the main function.
So here we had an opening curly brace and after all, the code inside we have the close curly brace.
So also an interesting thing is that you notice that I've been in dentin, like with a tab, the code
that is inside of these braces.
So that is not necessary.
C++ would still run it if they were at different indentation levels or they had no indentation at all.
But it's kind of good practice for readability and having clean code to indent things that are inside
of a function.
And we'll notice that we use indentation for other things besides functions in our code later on in
the course.
So it's kind of just a clean code, good practice thing.
So just to reiterate, everything in between these curly braces is part of the main function.
So you consider you can consider whatever Maine does to me, this stuff in here, it will.
See out, which means cancel out if we can all remember that the hell of my world string to the console
and then do an end line and then it will return zero to the operating system, they call it.
So that is something important to remember.
And also, one last thing to take away from this is the fact that we have these semicolons here.
So pretty much everything that is a statement in C++.
So not like this include, you know, which is kind of a pre processing thing.
And not the actual function definition, which we have for main here.
Everything that's not those is going to need to have a semicolon at the end.
OK, so hopefully that was enough of a look into this.
Hello, world.
Hello, my world in this case program and you're able to understand what was happening.
We're going to take a big step back in the next lectures and we're going to be looking at some very
primitive data types and things like that.
So we're kind of going to start from ground zero, but we want to know enough about how to run a C++
program to be able to add some more stuff in between these curly braces.
So the next little bit of the course is going to be us using this kind of as a template to be able to
add some more stuff in between here.
And we're not just going to see out Hello my world for every program right or see out.
We're not just going to put something else between.
Double quotes, because, you know, that's kind of a boring program, we're only just printing words
out to or words or numbers or wherever we put in between here out to the console.
We're going to try and print out some other data types that maybe aren't strings, and we're going to
look at what those data types are and then we're going to try and make some code that actually does
some more interesting stuff.
OK, so with that, I will see you in the next lecture.