Home>Article>Backend Development> What is the structure of the C language source program?

What is the structure of the C language source program?

青灯夜游
青灯夜游 Original
2020-10-27 16:13:24 4556browse

A C language source program can be composed of one or more source files, and each source file can be composed of one or more functions; no matter how many files a source program is composed of, there can only be one There is a main function, that is, the main function; defining a function must specify 4 elements: return type, function name, formal parameter list in parentheses (can be empty) and function body.

What is the structure of the C language source program?

Tutorial recommendation: "c language tutorial video"

At least one C language source program has a main function, Four elements must be specified to define a function: return type, function name, parameter list in parentheses (possibly empty), and function body. Structural characteristics of the source program:

1. A C language source program can be composed of one or more source files.

2. Each source file can be composed of one or more functions.

3. No matter how many files a source program consists of, there is one and only one main function, that is, the main function.

4. There can be preprocessing commands in the source program (the include command is only one of them). Preprocessing commands should usually be placed at the front of the source file or source program.

5. Every description and every statement must end with a semicolon. However, semicolons cannot be added after preprocessing commands, function headers and curly braces "}".

6. Identifiers and keywords must be separated by at least one space. If there are obvious separators, you can no longer add spaces to separate them.

7. In C language, there is a set of related control statements to implement selection structures and loop structures: selection control statements: if; switch, case. Loop control statements: for, while, do...while. Transfer control statements: break, continue, goto.

What is the structure of the C language source program?

Extended information

Unique features of C language

1. C language is a structured programming , a procedural language with variable scope and recursive functionality.

2. Parameters passed in C language are all passed by value (pass by value). In addition, a pointer can also be passed (a pointer passed by value).

3. Different variable types can be combined using structures (struct).

4. There are only 32 reserved keywords, which makes naming variables and functions more flexible.

5. Some variable types can be converted, such as integer and character variables.

6. Through pointers, C language can easily perform low-level control of memory.

7. Preprocessor makes C language compilation more flexible.

For more programming-related knowledge, please visit:Introduction to Programming! !

The above is the detailed content of What is the structure of the C language source program?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn