Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Modern C++: The Good Parts/Hello, world!

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

What are we waiting for? Here's your first C++ program. Save it in your editor (such as Qt Creator or Visual Studio), compile or build it, and run the executable. This will prove whether your compiler is working, which will be rather important for later exercises. Code #include <iostream> #include <string> int main() { std::cout << "Hello, world!\n"; } Explanation Those first two lines tell the compiler what includes (pre-existing code) we need. int main is required for any C++ program, and the logic inside the curly brackets is everything that will be done. The particular way that C++ requires us to arrange code is called its syntax. In this case, we send the text "Hello, world!" to the console. These first two chapters have been kept short to allow for complications with setting up your compiler, but following chapters will pick up the pace. Vocabulary includes files containing code that we can use in our own program. syntax the specific rules of a language, or basically what the language looks like. Getting a compiler Anatomy of a global greeting