User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







cpp:constant:define

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 

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
cpp/constant/define.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz