Table of Contents

define

  Constants and Macros
#include <iostream> /* including standard library */
 
    #define identifier     replacement_name
    #define identifier(identifier_list)     replacement_name

cpp Example 1

#include <iostream> /* including standard library */
 
 
#define ANSWER 42
 
using namespace std;
 
int main(void){
   cout << "the answer to life the universe and everything is " << ANSWER << endl;
}

output example 1

  the answer to life the universe and everything is 42 
  

C Example 2

#include <iostream> /* including standard library */
 
#define ANSWER 42
 
using namespace std;
 
int print ( void )
{
   cout << "the answer to life the universe and everything is " << ANSWER << endl;
   return 0;
}
 
int main(void)
{
   print();
return 0;
}

output example 2

  the answer to life the universe and everything is 42