
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
What is the #define Preprocessor in C++?
The #define creates a macro, which is the association of an identifier or parameterized identifier with a token string. After the macro is defined, the compiler can substitute the token string for each occurrence of the identifier in the source file.
#define identifier token-string
This is how the preprocessor is used. The #define directive causes the compiler to substitute token-string for each occurrence of identifier in the source file. The identifier is replaced only when it forms a token. That is, identifier is not replaced if it appears in a comment, in a string, or as part of a longer identifier.
example
#include<iostream> #define MY_VAR 55 using namespace std; int main() { int x = 10; cout << x + MY_VAR; // After preprocessing this expression becomes: x + 55 return 0; }
Output
This will give the output −
65
You can read more about the #define directive in MSDN https://docs.microsoft.com/en-us/cpp/preprocessor/hash-define-directive-c-cpp
- Related Articles
- C/C++ Preprocessor Directives
- How a Preprocessor works in C/C++?
- Convert C/C++ program to Preprocessor code\n
- What is the operator in MySQL?
- What is the breakpoint in PowerShell?
- What is the ?-->? operator in C++?
- What is the System.Reflection.Module in C#?
- What is the variation? What is the importance of variation?
- What is the purpose of ‘is’ operator in C#?
- What is the use of "is" keyword in C#?
- What is the largest earthquake in the world?
- What is the SNMP in the Computer Network?
- What is the MIB in the Computer Network?
- What is the HTTP in the Computer Network?
- What is the CDMA in the Computer Network?

Advertisements