【C】Introduction to C language and the first C language program

1. Language Introduction

C language is a general-purpose computer programming language, which is widely used in low-level development . The design goal of the C language is to provide a programming language that can be compiled in an easy way, handle low-level memory, generate a small amount of machine code, and can run without any operating environment support. Although the C language provides many low-level processing functions, it still maintains a good cross-platform feature. A C language program written in a standard specification can be compiled on many computer platforms, even including some embedded processors (single-chip or called MCU) and supercomputers and other operating platforms.
In the 1980s, in order to avoid differences in the C language grammar used by various developers, the US National Bureau of Standards formulated a complete set of American National Standard grammar for the C language, called ANSIC , as the initial standard of the C language. [1] At present, on December 8, 2011, the C11 standard issued by the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) is the third official standard of the C language and the latest standard of the C language. This standard is better It supports Chinese character function names and Chinese character identifiers, and realizes Chinese character programming to a certain extent.
C language is a process-oriented computer programming language, which is different from object-oriented programming languages ​​such as C++ and Java.
Its compilers mainly include Clang , GCC , WIN-TC, SUBLIME, MSVC , Turbo C, etc.

What needs to be explained here is that our C language is also divided into many versions, including C89, C90, C99, C11 and so on. Most of the syntax of the C language is defined in C89 and C90.

So what is underlying development?
Everyone knows that our computer is hardware, and the operating system (such as Windows, Mac, Linux, etc.) installed on the computer is our software (such as WeChat, QQ, etc.) on top of the operating system. There is also a driver in between to connect our computer and the operating system. We call the upper layer software above the operating system, and the lower layer software below it, also known as the bottom layer software.
Our C language is widely used in the development of underlying software.

2. The development history of C language

The C language was born very early. At that time, people were still accustomed to writing software in assembly language, and there was no unified, general-purpose operating system. Basically, software was written from zero. The goal of the C language is to be more convenient and easier to use than assembly without losing the expressive power of assembly. So the C language can be regarded as an "advanced assembly" language. The source code of the C language can basically correspond to the assembly code very easily, and there is no need for any runtime environment support. The characteristics of C, simple and easy to compile, flexible and close to the bottom layer. So until now, some software that needs to directly deal with hardware is still written in C language, such as (but not limited to) Linux Kernel and some embedded fields.
The approximate development process is: binary information -> assembly language -> B language -> C language.

3. Compile and link

When we write C language code, we write files with a suffix of .c. Such files need to be compiled -> linked -> and then an executable program with a suffix of .exe can be generated before they can be run.
The DevC++ and VS we use are integrated development environments, which integrate many sub-functions: editing, compiling, linking, running, debugging and so on. Our compiler is actually the process of compiling -> linking.

4. The first C language program

1. Next, I will introduce the first C language program to you.

#include<stdio.h>

//main是一个固定的名字
//main是主函数,是程序的入口,一个工程中有且只能有一个
//这里的int是整型
int main()
{
    
    
	//这里的printf是C语言的一个库函数,它的功能是打印内容在屏幕上
	printf("Hello World");
	//return 是返回
	return 0;
}
//在这里需要注意的是我们缩写的代码使用的符号都必须是英文的!!

Here I will explain #include<stdio.h> to everyone. stdio.h is a header file that contains functions such as printf. The meaning here is to include this header file in the way of #include.

2. The following is a very old way of writing (not recommended).

#include<stdio.h>
void main()
{
    
    
	printf("Hello World");
}

3. The following writing method is possible, where void means that the main function does not accept any parameters.

#include<stdio.h>
int main(void)
{
    
    
	printf("Hello World");
	return 0;
}

4. There is another way of writing, which is also possible.

#include<stdio.h>
int main(int argc, char* argv[])//其中int argc, char* argv[]表示main要接受的参数
{
    
    
	printf("Hello World");
	return 0;
}

This is the end of today's sharing, everyone is welcome to subscribe, and we will continue to update high-quality content in the future! !

Guess you like

Origin blog.csdn.net/bushibrnxiaohaij/article/details/131153325