A simple C + + program (get started for 17-level freshmen) __c++

Source: Internet
Author: User
Tags readable

Some time ago the department requested a small source to write a simple introductory guide to guide the 17-level newborn small white fast start C + + programming, small source wrote the following article, after the seniors change some small mistakes, can be published, here also write out to everyone, there are improper place also please reader Haihan.

Hey, by the way, raise your profile


Feng Qiyuan, Technical exchange and Promotion Department of Software Institute of South Central University


Class 17, you are good at school.

You are about to enter the Software Institute to learn, presumably for many people, "programming" is a strange and mysterious things, many movies have a description of hackers, milliseconds to break the security system, hidden in the dark and the villains to fight and so on.

Those are a little distant, but now we have to understand what the code and the program are.

First of all, a program is a set of command sequences written in computer language to achieve a specific goal or solve a particular problem, and a series of statements and instructions for the purpose of achieving the desired goal. The code, however, can be seen as part of a program, a line or a few lines, to complete some tasks. Individual code has no meaning, and only in a particular program is it useful to be interpreted as a program that the computer can execute.

In simple terms, a program is made up of code.

The code, written by the programmer in the language supported by the development tool, is a set of strings represented by characters, symbols, and so on. The programmer writes the code in the language is the human readable form, the computer source code ultimate goal is translates the human readable text into the computer executable binary instruction, this process is called compiles, it completes through the compiler.

The compiler is so convenient for programmers to learn and work. We typically write code in an integrated development environment and then compile and run it. Some people now write code using the code compiler, but these tools only install specific plug-ins before code compiles. (it is said that some great gods use Notepad to write code) in our study of C + +, relatively simple compiler is dev-c++ and codeblocks, small but many functions, to meet the normal writing of a single code is no problem, but if the engineering writing code will need to use a more powerful compiler. Microsoft Visual Studio, referred to as vs. Is the United States Microsoft's Development Toolkit products. There are several versions of this series, but because many companies do not use the latest version of the development process, and the latest version has to pay for the purchase (this is not a big deal, there are ways to activate), the general use of VS2013 or VS2015 on it, of course, can also use the latest VS2017. Some features may be slightly different between versions, but they are generally consistent, and code written in different versions may have problems with versioning and so on.

Below I use the dev-c++ compiler to run a demo of the simplest C + + program. Installation is also convenient, the VS compiler installation is a bit complicated.

This is the initial interface of the compiler, there is no display, now we can click on the menu bar "file"-> "new"-> "source code", or click "File" under the white flag. You can enter the authoring interface. 、


I wrote 7 lines of code, the first line is #include<>, in short, to introduce the contents of other files into this file, usually the header file, that is, the suffix of the file is. h. Starting with the int main () {} of the third line, the main writing is generally here, in the curly braces of the int main function. Line 5th means the output of a string "HelloWorld", and the 6th line Return0 represents the end of the entire program. Be sure to remember that every code has to be separated by a semicolon to represent the end of the sentence.


Click on the menu bar "Run", click Compile Run, or F11 shortcut key


To select the storage location and file name, you can see that the suffix of this file name is. cpp, which is the C + + source file, because C + + is the full name of "C Plus plus"

Click Save to eject a run box


You can see the HelloWorld being output in this box. This is a simple C + + program to run the demo.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.