C Programming Language Introduction
C is a general-purpose computer programming language that is widely used in low-level development. C was designed to provide a programming language that can be compiled in an easy way, handle low-level memory, generate small amounts of machine code, and run without any runtime environment support.
Table of Contents
C Programming Language History
The C language was born at Bell Labs in the United States, developed by Dennis Ritchie on the basis of the B language designed by Kenneth Lane Thompson.
In 1967, Martin Richards of Cambridge University simplified the CPL language, resulting in the BCPL (Basic Combinatorial Programming Language) language.
In the 1960s, Ken Thompson, a researcher at Bell Labs, developed an operating system for PDP-7 in order to play a video game he coded himself – Space Travel. Later, this operating system was named – UNICS (Uniplexed Information and Computing Service).
In 1971, Dennis Ritchie, who also liked Space Travel, joined Thompson’s development project to collaborate on UNIX in order to play the game earlier, and his main task was to tweak the B language to make it more mature.
In 1972, Dennis Ritchie finally designed a new language based on the B language, and he took the second letter of BCPL as the name of this language, which was C.
C Programming Language Standard
In 1989, the American National Standards Institute published the first complete standard for the C language, ANSI X3.159-1989, or “C89” for short. C89 was adopted by the International Organization for Standardization (ISO) in 1990, and the official name given by ISO is ISO/IEC 9899, so ISO/IEC 9899:1990 is also commonly referred to as “C90 “.
In 1999, after making some necessary changes and improvements, ISO published a new C language standard named ISO/IEC 9899:1999, or “C99” for short.
On December 8, 2011, ISO officially released a new standard named ISO/IEC 9899:2011, abbreviated as “C11”.
In June 2018, ISO published the latest ISO/IEC 9899:2018 standard, which is the latest C programming language standard to date, to replace the C11 standard, referred to as “C17” or “C18”.
The next version of the C standard is expected to be completed by December 1, 2022.
There were many proposals to add object-oriented features to C, including classes, inheritance, polymorphism, and other syntactic features already widely used in C++, but they were all rejected by the committee. These complex syntactic features were rejected by the committee because they were inconsistent with the design philosophy and design ideas of the C language. Moreover, C++ already has these features, and C does not need to support them.
Why Learn C?
- C can be used as an entry-level language for learning computer programming languages.
- C is the language of choice for writing operating systems and is dexterous and efficient when dealing with computer hardware.
- C has the basic syntactic features of modern high-level programming languages.
- Commonly used object-oriented programming languages, such as C++ and Java, derive their basic syntax from C.
- Many software systems written in C have to be maintained.
- Used for writing in areas that require programs to run at high speed, such as microcontroller programs, embedded system software, and communication programs.
- A large number of users and enthusiasts of the C language.
Note:
Other features of the C programming language
- Structured design language with clear syntax and simple structure, modularity makes the parts of the program independent of each other except for the necessary information exchange, easy to develop and debug.
- Many operators, such as brackets, assignment, and forced type conversion, are treated as operators, and the flexible use of various operators can achieve operations that are difficult to achieve in other high-level languages.
- Data structures are rich and can realize various complex data type operations. The concept of pointer is introduced and the structure makes the program more efficient.
- Built for operating systems, it can operate on bits, bytes and addresses like assembly language, allowing direct access to physical addresses for operations, combining the basic structure and statements of a high-level language with the practicality of a low-level language.
- Program execution is efficient, typically 10% to 20% less efficient than the target code generated by assembly programs.
- C abstracts the details of CPU programming and can be used extensively to write software for large operating systems and systems.
- It has powerful drawing capabilities and can write elegant 2D and 3D graphics and animations, just like C++.
C compilation
C is a compiled language and the source code is a text file that cannot be executed by itself. It must be compiled to produce a binary executable file that can be executed. The process by which the compiler translates the code from text to binary instructions is called the compilation phase, also known as “compile time”, and is distinguished from the runtime phase (also known as “runtime”).
Currently, the most common C compiler is the GCC compiler from the Free Software Foundation, which is free to use. GCC can be installed directly on Linux and Mac systems, and MinGW can be installed on Windows systems.
The first C program
A C program, which can be a few lines or millions of lines, can be written in one or more text files with the extension “.c“, for example, hello.c. You can use “vi“, “vim” or any other text editor to write your C program.
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
#include
Include the stdio.h header file into the program. stdio, standard intput output, contains a series of library functions.
main
is the main function, which is the beginning of a program and is an essential part of it.
int
means that the return value of this function is an integer.
printf
is also a function, where this function is used to output a string.
return
is used to return the value.
The beginning and end of a function are enclosed by {}.
0 Comments