0 day streak
c / beginner
Snippet

Defining Constants with #define

The #define directive creates a symbolic constant. The preprocessor replaces every occurrence of the name with the value before compilation, making the code easier to maintain.

snippet.c
c
1
2
3
4
#define MAX_SCORE 100
#define VERSION 1
int currentScore = 85;
Breakdown
1
#define MAX_SCORE 100
Tells the preprocessor to replace MAX_SCORE with 100 throughout the code.