Search
 
SCRIPT & CODE EXAMPLE
 

CPP

macro c++

#include <isotream>
#define print(x) std::cout << x << std::endl

int main(){
  std::string sentence = "Hello World!";
  print(sentence); // OUTPUT: Hello World!
}
Comment

cpp macro

#define PRINT(x) std::cout << x << std::endl
Comment

cpp macro

//INCLUDING BUILT-IN LIBRARIES...
#include <iostream>
#include <stdlib.h>
//PRE-DEFINE CONSTANT VALUES...
#define MAXNUM -12    //defining an integer
#define PI 3.1415     //defining a float
#define END "

		Program has ended!!
"   //defining a string
//PRE-DEFINING CONSTANT OPERATIONS...
#define ADD(a, b, c) (a + b + c)    //Operation that will add its 3 parameters

using namespace std;

int main(){
    //using other definitions to check if the current device is Windows or UNIX
    #ifdef _WIN32  
        cout<<"Windows Operating System Detected"<<endl;
    #elif __unix__
        cout<<"UNIX Operating System Detected"<<endl;
    #else
        cout<<"Operating System could NOT be identified!"<<endl;
    #endif
    
    cout<<endl<<"Using pre-defined values and operations: "<<endl;
    cout<<" • MAXNUM: "<<MAXNUM<<endl;       //using pre-defined integer
    cout<<" • PI: "<<PI<<endl;               //using pre-defined float
    cout<<" • ADD(): "<<ADD(2,5,99.5)<<endl;   //using pre-defined function

    cout<<END;    //using pre-defined string
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to string to integer in c++ 
Cpp :: difference between lower and upper bound 
Cpp :: roscpp publish int32 
Cpp :: c++ program to find prime number using function 
Cpp :: c++ hours minutes seconds 
Cpp :: how to iterate from second element in map c++ 
Cpp :: factorial in c++ 
Cpp :: reverse c++ 
Cpp :: string to int in c++ 
Cpp :: C++ Find the sum of first n Natural Numbers 
Cpp :: c++ function as param 
Cpp :: sleep system function linux c++ 
Cpp :: C++ Swap 2 Variables Without Using 3rd Variable 
Cpp :: abs in c++ 
Cpp :: find max value in array c++ 
Cpp :: c++ find_if 
Cpp :: read comma separated text file in c++ 
Cpp :: setprecision c++ 
Cpp :: c vs c++ 
Cpp :: how to create a vector in c++ 
Cpp :: C++ structure (Struct) 
Cpp :: vector length c++ 
Cpp :: c++ how to add something at the start of a vector 
Cpp :: how to split string in c++ 
Cpp :: stack implementation using class in c++ 
Cpp :: c++ pass array to a function 
Cpp :: c++ progress bar 
Cpp :: cpp func as const 
Cpp :: C++ float and double Different Precisions For Different Variables 
Cpp :: convert integer to string in c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =