Current location - Training Enrollment Network - Mathematics courses - What is the program of C language?
What is the program of C language?
C language source program consists of data types, constants and variables, arrays, pointers, strings and file input/output.

Specific introduction:

1, data type

The data types of C include integer type, character type, real number type or floating point type (single precision and double precision), enumeration type, array type, structure type, * * * * object type, pointer type and null type.

2. Constant and variable

Constants have unchangeable values, and symbolic constant names are usually capitalized. A variable is a quantity whose value can be changed under the name of an identifier. An identifier is a series of letters, numbers or underscores that begin with a letter or underscore. Please note that the first character must be a letter or an underscore, otherwise it is an illegal variable name. Variables are assigned corresponding storage locations at compile time.

Step 3 arrange

If the variable name is followed by a number bracket, the declaration is an array declaration. Strings are also arrays. They end the array with ASCII NULL. It should be noted that the index values in square brackets are counted from 0.

4. Pointer

Pointers can be not only the addresses of variables, but also the addresses of arrays, array elements and functions. Pointers can be used as formal parameters to get multiple return values in the process of function calling, unlike return(z) which can only get one return value.

Pointer is a double-edged sword, and many operations can be expressed naturally through pointer, but incorrect or excessive use of pointer will bring many potential errors to the program.

5. Line

The string in C language is actually a char array ending with the character' \0'. You don't need a reference library to use character types, but you need some functions in the C standard library to operate on strings. They are different from character arrays.

6. File input/output

In C language, input and output are realized by a set of functions in the standard library. In ANSI C, these functions are defined in the header file.

Extended data:

language feature

1. High-level language: It is a work unit that combines the basic structure and sentences of high-level language with the practicality of low-level language.

2. Structured language: The notable feature of structured language is the separation of code and data, that is, all parts of the program are independent of each other except the necessary information exchange. This structured way can make the program clear and easy to use, maintain and debug.

3. Cross-platform code level: Due to the existence of standards, almost the same C code can be used in many operating systems, such as Windows, DOS, UNIX, etc. It is also suitable for various models. C language is superior to other high-level languages when hardware operation is needed for writing.

4, the use of pointers: you can directly close to the hardware operation, but the pointer operation of C is not protected, which also brings many unsafe factors to it. C++ has made improvements in this respect, and it has been supported by some users while retaining pointer operation.