Basic GCC usage

Source: Internet
Author: User
GCC test. C will compile a file named A. Out. ProgramGCC test. c-o test will compile a program named test. The-O parameter is used to specify the name of the program to be generated, if your program is placed under c: \, make sure that the DOS root directory is in the DOS window, that is, the DOS window must be displayed as c: \>, if it is not changed through the CD command. For example, I created a file in drive C. // File Code# Include <iostream> using namespace STD; int main () {cout <"Hello, world" ;}and save it as hello. CPP open the DOS window and find that the DOS window displays F: \> I typed C: And then press enter to return to the C drive and then type G ++ hello. after compilation of CPP-O hellothis example, A hello.exe file will be displayed in the C drive, and then type hello in the DOS window. The result is displayed. Next, let's talk about how to directly compile the program in Vim. First, install vim, after installation, add the following code to _ vimrc: "set the file browser directory to the current directory set bsdir = bufferset autochdir. In this way, VIM directly transfers the DOS directory to the edited directory, you can use: CD to check whether the directory is correct. Then write a program in vim and save a location. It is best to confirm this location, because if it changes frequently, it will cause errors, and then input the following command in VIM :! G ++ filename. cpp-O filename where filename is your saved file name and CPP is the program type. After the compilation is complete, type :! Filename. Or directly write the command: Make filename in vim.

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.