9
Since the two do the same function there is some difference between one and the other?
I’ll take the code from this site as an example C - Constants & Literals
The #define Preprocessor
#include <stdio.h>
#define LENGTH 10
#define WIDTH 5
#define NEWLINE '\n'
int main() {
int area;
area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);
return 0;
}
When code is compiled and executed it reproduces the following result:
value of area : 50
The const Keyword
#include <stdio.h>
int main() {
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = '\n';
int area;
area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);
return 0;
}
When code is compiled and executed it reproduces the following result:
value of area : 50
vlw @bigown now I’ll stay tuned when I have to use const and #defines +1
– user45474