Preface, This article describes the use of Linux Systems to write C + + Language program is implemented in the CentOS Environment, before programming, you must first install Linux System or Linux virtual machines, everything is ready so we can start programming.
(1) . turn on your computer or Linux Virtual Machine (I'm using a virtual machine)
650) this.width=650; "Width=" 553 "height=" 262 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
(2) Create a file
In the top left corner , click Applications, System Tools , terminal
650) this.width=650; "Width=" 553 "height=" 205 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Get the following results
650) this.width=650; "Width=" 554 "height=" 303 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
(3) Edit File
In the input box, type vim hello.c// here vim refers to creating a file. Hello.chello is the file name can be arbitrarily taken,
. C is a file type, here refers to creating a C file named Hello
650) this.width=650; "Width=" 554 "height=" 171 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Press the ENTER key to get
650) this.width=650; "Width=" 554 "height=" 366 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Press the character key ' I '
650) this.width=650; "Width=" 554 "height=" 384 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Start typing a C language file (here we enter an error code to see how to debug the changes), for example:
650) this.width=650; "Width=" 554 "height=" 386 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
In the program above, I no longer have a semicolon behind printf.
Now we save this program, save method:1. Press the ESC "key. 2. Enter the : wq! ". 3. press ENTER.
Note: The characters inside the double quotes cannot be less!
The process and results are as follows:
upon completion of step 2 :
650) this.width=650; "Width=" 554 "height=" 386 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
After you press ENTER:
650) this.width=650; "Width=" 554 "height=" 168 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
(4) Commissioning and Operation
First compile, enter gcc hello.c-o Hello and press Enter
The function is to build the C file,hello.c compile the hello.obj file
If you are writing a C + + file, enter g++ hello.cpp-o Hello
Before you press ENTER
650) this.width=650; "Width=" 554 "height=" 153 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
After you press ENTER
650) this.width=650; "Width=" 554 "height=" 144 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Look at the above gives the error prompt, we have to modify the error,
Input vim hello.c
650) this.width=650; "Width=" 554 "height=" 149 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Press ENTER
650) this.width=650; "Width=" 554 "height=" 376 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Now see this interface can not be modified, need to press 'A' on the keyboard, the results are as follows, see what is different from the above
650) this.width=650; "Width=" 554 "height=" 388 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Modify the error (plus our semicolon)
and press ESC and enter : wq!
650) this.width=650; "Width=" 554 "height=" 387 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Press ENTER
650) this.width=650; "Width=" 554 "height=" 192 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Now input gcc hello.c-o Hello
650) this.width=650; "Width=" 554 "height=" 173 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Press ENTER to compile successfully without error
650) this.width=650; "Width=" 554 "height=" 169 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
Enter ./hello and press ENTER to run the program you wrote
650) this.width=650; "Width=" 554 "height=" 192 "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") No-repeat center;border:1px solid #ddd; "src="/e/u261/themes/default/images/spacer.gif "alt=" Spacer.gif "/>
The reason for the top "Hello Word! " "is linked to the statement behind it because I don't have a semicolon.
If you are writing a C + + program, just change gcc to g++ and . C to . cpp .
The specific process is on the top, I am also a beginner, if the great God found that there is a wrong place, you are welcome to criticize correct!
This article is from the "Sharing Progress" blog, be sure to keep this source http://xmwen1.blog.51cto.com/10730069/1706391
How the Linux system writes A/C + + program