define
Constants and Macros
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#define identifier replacement_name
#define identifier(identifier_list) replacement_name
C Example 1
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#define ANSWER 42
int main(void){
printf("the answer to life the universe and everything is %d \n", ANSWER );
}
output example 1
user@host:~$ ./define
the answer to life the universe and everything is 42
C Example 2
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#define ANSWER 42
int print ( void )
{
printf("the answer to life the universe and everything is %d \n", ANSWER );
return 0;
}
int main(void)
{
print();
return 0;
}
output example 2
user@host:~$ ./define
the answer to life the universe and everything is 42