Linux C Programming Learning

Source: Internet
Author: User

Introduction to C language Introduction

C language has strong control characteristics, high efficiency, portability and powerful functions and flexibility. "The price of freedom is always vigilant", the simplicity of C is combined with its rich operators, making it possible to write more difficult-to-understand code. Object-oriented programming is a philosophical idea that attempts to adapt a language to a problem rather than to adapt it to a language. C is a process-oriented or function-oriented programming, and C + + is an object-oriented programming of a C superset.

C language operating mechanism

The basic strategy of C programming is to use the program to convert the source code into an executable file that contains the machine language code that can be run. C Implementation of this goal is mainly achieved through two steps: Compile and link. The compiler translates the source code into intermediate code, and the linker combines the intermediate code with the other code to build the executable file. The intermediate file generally refers to the target file, which converts the source code into a machine language code and places the result in the target file. However, the target file cannot be run because the file contains the conversion result of the source code and is not a complete program. The target code is missing two parts: the code for the startup code and for the library routine start-up .

startup code : equivalent to the interface between the program and the OS. If DOS and Linux PC hardware are the same, they will use the same target code. (The same hardware is the same as their machine language instruction set, so they will produce the same target code) they want to use different boot code, because the two system handlers are different in the same way. But with the same hardware, the machine language produced by the target file is executed by both machines.

code for the library routine: Some library programs for C languages. For example: "Stdio.h"

The purpose of the linker is to combine the code of the target file, the startup code, and the library routines, and store them in a file to execute the file.

Both the target file and the executable file are made up of machine language directives.

For example:

 Create test.c source code, source code:

  

Then build the executable file with GCC compilation

The compiler recognizes a C source code file by checking the suffix name of the file specified on the command line. GCC Default action: Compile the source code file to generate object file, link object file get executable program, delete object file. The compiler takes the default a.out because the executable program's file name is not specified in the command line.

Note: Review the entire process of compiling C source code in detail. Hit me.

Linux C Programming Learning

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.