Since the two do the same function is there any 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 the 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 the code is compiled and executed it reproduces the following result:
value of area: 50