Use vim compiled .cpp file

First, write code

1, open a command line terminal, enter vim test.cpp, created a new file called "test.cpp"; if the file had previously been established, it is the name of the file to open.

2. Press Enter to enter the edit screen, enter i to enter edit mode, start writing program

3, after the program is finished, press the enter key esc launch edit mode and return to the command line mode, enter: show Save "w", then type ": q" to exit the vim editor; you can directly enter ": wq" Direct the completion of these two steps.

 

Second, compiled code

At the command line, type g ++ -Wall test.cpp -o test compiled code (note to Wall uppercase W)

This command code is compiled files 'test.cpp' and stored in the machine code in the executable file 'test' in. Machine code file name is specified by the -o option, which is usually used as the last argument on the command line. If omitted, the default is the output file 'a.out'.

Note that if the current directory with the same name as the executable file already exists, it will be covered.

Third, run the code

At the command line, type ./test

Path "./" refers to the current directory, so "./test" loading and execution of the executable file in the current directory 'test'.

 

After running, the program according to the input data, outputs a corresponding result will

Guess you like

Origin www.cnblogs.com/-citywall123/p/11374352.html