In this video, I'll show you a couple of options that allow you to run your c++ programs
right in a web browser.
Now this is pretty nice because sometimes you're on the road, you don't have your computer with you
and you want to take the the course and try out some examples,
maybe you had an idea about an example you want to try it out but nothing's available
or your friend's house, and there's no computer available there except the browser.
All you need is a browser to run these.
One example is if you open up your favorite browser I'm using chrome here,
you can type in cpp.sh. That's the URL.
And you get the c++ shell.
Now both of these examples I'm going to show you
are rather limited compared to obviously running on your own
computer with an IDE and so forth.
But they're really, really handy when you need to try something out really quickly
without having to install a thing. So in this case, cpp.sh
is the c++ plus shell.
You can type your program right in here on the browser.
And you can see here I've typed in the hello world program.
And you can set options. You can set your c++14 options,
your warnings to a wall, like we have in the examples.
And if you want to run your program, you can just select run.
And it's going to compile and run it at the same time, which is pretty nice.
Also, if the program asks for input, which we'll get to a little bit later in the course,
you can set that to interactive mode. So it'll be able to -- you'll be able to type into the program,
which is kind of nice as well. So in this case, I want to run the program.
And you can see it's compiling.
Program is running, and the output is hello world right here,
and the exit code is 0, which is our return 0.
That's pretty nice. Now you can get a URL,
which gets a URL to what you did.
And you can click on that URL and you got the program that you wrote back.
So that's obviously it's storing it somewhere.
I'm not sure where or how long it's going to be available,
but you can figure that out if you like. That's one example.
Another example is
webcompiler.cloudapp.net.
This is a visual c++ plus compiler running in the web. It's a Microsoft compiler.
And you can see that they've given you a sample program here.
Now this text is pretty small. Again, it's a browser. So I'm going to make my browser a little bit bigger.
So you can see it and then I'll make it a little smaller again to run it.
So you can see here it's including iostream. It's using a namespace, which we'll talk about a little bit later
and it's outputting hello world.
And let me make this a little smaller again. So when you run the program
by clicking this purple button down here,
there's your output right up here in this black window here hello world,
which is pretty nice. And you can set your compiler flags,
however, you like. So in this case I'm setting the warnings to all, and I'm setting my
standard compiler to c++14.
I'll close that down. And so as you can see
this is pretty nice option here. We can -- if we get a compiler error let's
say we forget that semicolon and we run,
then the compiler error shows up down here, it says in function main,
on line 7 right here.
There's a semicolon expected. You actually get a little red
little x there that tells you the arrows right around here somewhere, so you can fix your error
and run it again.
And there you go. There's your hello world. So again, these are some web-based options.
They're not perfect. You can't really save things and edit
and do all kinds of good stuff, but
you can run a lot of the programs that we're going to talk
about in this class, right in the ++ shell on the web.