[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; }