#define constant declaration

Asked 1 years ago, Updated 1 years ago, 275 views

For example, is it wrong to write #defineTAX0.5f like this?

c

2023-03-13 18:21

1 Answers

In C or C++ languages, pre-processing statements that begin with # are called preprocessing statements.

#define has several uses. As I asked, #defineAB finds all the same spelling as A in the code before compiling and replaces it with B.

After the replacement is finished, proceed with the compilation.

For example,

#define TAX 0.5f
float t=TAX;

The above code will be compiled after being replaced as shown below.

float t=0.5f;

When defined as #defineAB, A is usually referred to as a constant (or macro constant, also known as a symbol constant).

As I asked, the text A is replaced with B itself.


2023-03-14 11:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.