C Tutorial/Preprocessor/define
Use #define to define constant
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define BS "\b"
#define TAB "\011"
main(){
printf("%d",TRUE);
printf("%d",FALSE);
printf("%c",BS);
printf("%d",TAB);
}
19
Use preprocessor to define integer and string
#include <stdio.h>
#define VAL 35
#define HELLO "HELLO"
main ()
{
int res;
res = VAL-5;
printf ("res = VAL-5: res == %d\n", res);
printf ("%s",HELLO);
}
res = VAL-5: res == 30 HELLO