Home  >  Article  >  Backend Development  >  What does define mean in C language?

What does define mean in C language?

藏色散人
藏色散人Original
2020-02-20 10:22:4632747browse

What does define mean in C language?

What does define in c language mean?

means definition, forcing a variable to be the value you want. For example, #define PI 3.14 defines the value of PI as 3.14, so that when you see PI in the program, you can replace it with 3.14.

Recommended: "c Language Tutorial"

The amount whose value can be changed during the execution of the program is called a variable. Variable types are divided into system variables and user-defined variable.

User-defined variables actually have the same meaning as system variables. When you learn structured programming, you will understand the meaning of custom variables.

System variables are divided into four types:

1, int integer variable;

2, user variable for storing integers;

3, 4 The size of bytes; float single-precision floating-point type, which stores the decimal point value; occupies 4 bytes; double high-precision floating-point type. Compared with float, double retains more precise decimal point digits,

4. It occupies 8 bytes in size; char character variable mainly stores letters and occupies 1 byte in size.

Simple define definition

#define MAXTIME 1000

A simple MAXTIME is defined, which represents 1000. If you write

if(i<MAXTIME){.........}

in the program, the compiler will Process and replace MAXTIME with 1000.

This definition looks similar to the ordinary constant definition CONST, but it is also different, because the definition of define is more like a simple text replacement, rather than being used as a quantity. This problem is reflected below Especially prominent.

For more programming related content, please pay attention to the Programming Introduction column on the php Chinese website!

The above is the detailed content of What does define mean in C language?. 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
Previous article:How to read excel in c++Next article:How to read excel in c++