This is my first day learning C++ using Accelerated C++ by Koenig.
I have a "Hello World" script saved as a .cpp file.
I've just installed Visual Express and opened it.
I've read the directions inasmuch as the word "compile" appears in them.
I can't figure out how to compile my Hello World.
Any help is much appreciated!
Thank you! I think it compiled but I was expecting a DOS window to pop up with "Hello World" in it. I'm guessing that compiling creates the .exe file but doesn't actually run the script? What do I type to see the finished product?
What you call a DOS window is actually called a console window. It looks like DOS did, but it has nothing to do with it.
The word script usually refers to code that is not compiled into machine code, but rather interpreted at run time. C++ is a compiled language. This means that once we compile our source code, the original .cpp files are not linked in any way to the compiled program. The resulting program can be ran independently (provided, of course, you have the required runtimes installed, when needed).
As to your problem, VC++ must be running the program and closing the window after it's done. Try inserting a statement that will wait for using input at the end of the program, such as:
1 2
char c;
std::cin >> c;
Note this is just a quick fix, there are better ways to do this.