Note 01_ C language description & environment settings & compiler execution

Foreword

I as a front-end developer into the programming world, after the passage of time, I found something for the underlying programming is not know, just stick surface, so I want to try to learn C language and then further understand the underlying mechanisms.

Introduction

C is a universal language, the computer program for procedural languages.

Was originally developed by Dennis Ritchie at Bell Labs for the development of the UNIX operating system is designed.

In 1978, Brian Kelin Han (Brian Kernighan) and Dennis Ritchie (Dennis Ritchie) made the first publicly available description of C, now known as K & R standard.

Most current C language standard C11, before it is standard C language C99.

UNIX operating system, C compiler, and almost all UNIX applications are written in C language.

c language online editor will let you write c program in case of no pre-built environment

advantage

  • Structured language.
  • It produces high-efficiency programs.
  • It can handle low-level activities.
  • It can be compiled on a variety of computer platforms.

About C

  • C language is a language-based B, B is probably the language was introduced in 1970.

  • C language standard was developed in 1988 by the American National Standards Institute.

  • Currently, C programming language is the system most widely used language.

  • It is the most advanced software in C language.

  • Today's most popular Linux operating system and MySQL are using the C language.

Why use C?

C language was originally used for system development work, especially procedures of the operating system. Since the C language code generated by the speed written in assembly language code is almost the same speed, so as the system using C language development language. The following are a few examples of the use of the C:

  • operating system
  • Compiler
  • Assembler
  • text editor
  • printer
  • Network Drive
  • Modern procedures
  • database
  • Language interpreter
  • Entity tool

C program

A C language program that can be three lines, it can be millions of rows, it can be written in one or more extension ".c" text file, for example, hello.c .

hello.c

#include <stdio.h>
 
int main()
{
    /* 我的第一个 C 程序 */
    printf("Hello, World! \n");
 
    return 0;
}
  • All c programs need to include a main () function. The code from the () main function begins execution.
  • / * ... * / for explanatory notes.
  • printf () for outputting the content to the screen in parentheses. printf () function in the "stdio.h" header file declares.
  • stdio.h is a header file (standard input and output headers), #include is a preprocessor for introducing header. When the compiler encounters printf () function, the If you do not find stdio.h header file, the compiler error occurs.
  • return 0; statement indicates that exit the program.

Environment settings

text editor

You can choose a pre own favorite text editor, files created by editors commonly referred to as the source file, the source file containing the source code. C program source files usually use the extension " .c ."

C Compiler

C language compiler is used to compile source code into executable programs.

The most popular free compiler is available in the GNU C / C ++ compiler

Installation on UNIX / Linux

If you are using a Linux or UNIX , at the command line using the following command to check on your system, the GCC is installed:

$ gcc -v

If your computer has installed the GNU compiler, version information is displayed

If the GCC is not installed, then follow http://gcc.gnu.org/install/ install GCC detailed instructions on.

Installation on Mac OS

The basic system can be built by gcc command-line tool gcc -vto view, if not you can use the brew install gcccommand to install, provided there is a brew tool on your computer, this usually comes with.

Installation on Windows

In order to install GCC on Windows, you need to install MinGW. In order to install MinGW, please visit the homepage of MinGW www.mingw.org , into the MinGW download page and download the latest version of MinGW installer, named format MinGW-<version>.exe.

When installing MinWG, that you at least want to install gcc-core, gcc-g ++, binutils and MinGW runtime, but generally will install more other items.

Add your MinGW installation bin subdirectory in your PATH environment variable, so you can specify these tools through a simple name on the command line.

When the installation is complete, you can run gcc, g ++, ar, ranlib, dlltool and some other GNU tools from the Windows command line.

Compiler implementation

  1. The above hello.csave the file,

  2. Open a command-line tool, go to the directory where you saved the file is located.
  3. Enter gcc hello.c, Enter, compile.
  4. If there are no errors in the code, the command prompt will jump to the next line, and generates a.out executable file.
  5. In the command line ./a.outwill execute the program.
  6. Displays Heelo, World! Onto the page.

Guess you like

Origin www.cnblogs.com/rope/p/11969279.html