[C Language] compile and execute the program on the command line.

Source: Internet
Author: User

[C Language] compile and execute the program on the command line.

Bytes -----------------------------------------------------------------------------------------

1. Before writing C language on Mac and Linux, first check whether the compiler is installed:

Enter gcc in the terminal and press enter to check whether the gcc file is installed. If yes, the system prompts clang: error: no input files (no input file );

 

If no installation is available, install Xcode or gcc compiler as prompted on Mac. In CentOS, run yum-y install gcc-c ++ (-y indicates that y is automatically selected)

 

--------------------------- @ Blackeye poet <www. chenwei. ws> ----------------------------

 

2. Now start to write code happily:

Use command + R in Xcode to directly compile and run your c code.

 

On a Mac terminal, use the vim tool, such as vim test. c. It will not help you create test. c. After writing the c code, you need command + s to save it, And then: wq! Exit, use the command gcc test. c to compile, without specifying the compiled file name. The compiled file name will all be a. out. Run it to use./a. out.

 

In Linux, vim is also used. When vim test. c is input, the test. c file is created in the current directory. After writing c code, wq is directly used! Save and exit. Use gcc test. c to compile and run the compiling file./a. out.

 

Sublime Text is a Text editor worth using. if the environment is installed, use cmd + B to compile the code, shift + cmd + B to run, but Sublime can only run one program, to run an input program, you must leave Sublime to enter the terminal.

  

Windows environment C/C ++ integrated development environment (IDE) recommended Dev-C ++, here not too much introduction, here: http://sourceforge.net/projects/orwelldevcpp? Source = directory.

 

3. DEMO:

#include "stdio.h"int main(){  printf("nihao,shijie! \n"); //nihao, shijie

printf("12+12=%d", 12+12); //12+12=24
return 0; }

 

Related Article

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.