How to create a C + + program

Source: Internet
Author: User

Download Microsoft Visual C + + 6.0 Click here: VC 6.0 download (including English version) (Support Win7 and XP)

First, we'll go into the Microsoft Visual C + + integrated development environment (Integrated Develop Environment, or IDE) and double-click the icon. After entering, we can see the following interface.


Figure 1-1 VC 6.0 start-up interface


Click on the File menu in the upper-left corner and select new to jump out of the dialog box below.


Figure 1-2 Creating a project


Figure 1-2 is located in the project (Project) tab. The design process is like building a house requires drawings, building materials, and building tools, as well as a variety of things, such as program code, header files, or some additional resources. These things are put in a project. Projects can help coordinate the organization of these files and resources, making the design more orderly and easier to find.

Note that each project can only correspond to a design program, do not put a number of programs peremptorily plug in a project!

The left part is the choice of the project type, i.e. what type of program we want to design. What we want to learn is the console application, so choose Win32 Console Application (). Project name on the right is the project names and should not be difficult to understand. Location is the site of the project, if you are not clear about the concept of saving location, then please refer to some beginner's reference books. To illustrate, when a new project is created under Location, a new folder named after the project name will be created in this position. You can open the project by opening the "project name. DSW" file in this folder.

Choose a good type, fill out the project name and save location, press "OK", and then the following dialog box appears.


Figure 1-3 Selecting a console app type


This dialog box asks us which console application we want to create, and we want to create a "hello,world! "The example program, so we chose the third item () A" hello,world! "Application.

Think about it, if we're going to make a console application ourselves, which one should we choose?

When you click Finish, a message box pops up about the new project information, and after clicking OK again, the sample project appears. Find the workspace box (in fact there is no name on this box, the box is on the left side of the entire integrated development environment), click File View to open all the tree-like directories, such as.


Figure 1-4 Workspace Box


We can see three folder structures, source files, header files (header file), and resource files (resource file). Source files are mainly stored in the design of the main program code, the header file is mainly to store some preprocessing files (about what is pre-processing files, will be introduced later), resource files are generally stored some of the necessary resources to run the program, such as, text and other types of files. However, the folder structure here is not the folder structure on disk, but just the classification of these files in the project. So, if you don't have a folder of these names created by yourself, you can't find them in your project.

Double-click a file to view its contents. This section only describes how to create a program, so the code within each file is not described.

Finally, I want to show you how to make a well-designed program run. First open the main program code file (in this case StdAfx.cpp), then click the Build menu, then click Compile StdAfx.cpp (Compile). Compiling is the use of compiler software to translate high-level languages that we can easily master into low-level languages that computers recognize. If it is not compiled (or interpreted), the program code of the high-level language cannot be executed.

Once the compilation is complete, click the Build menu again to build the project name. EXE (in this case, CppDemo.exe). We often refer to this process as a connection (linking), which is to integrate the program modules of multiple source files. When a program is large in size, the connection becomes one of the key steps to ensure that the program can function properly.

Finally, click the Execute project name in the Build menu. EXE (in this case, CppDemo.exe), which executes, runs the program and looks at the results, as shown in. You can use shortcut keys or shortcut buttons when you are skilled. If the code is correct and compile correctly, but the build has a hint of an error, check to see if it was not closed after the program was last run.


Figure 1-5 Program runs successfully

How to create a C + + program

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.