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

Macros in c++

#define var(datatype, name, value) datatype name = value;

int main()
{
 var(string, hello, "Hello World!");
 cout << hello;
 
 //Hello World!
}
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 :: using find in vector c++ 
Cpp :: how to open and print in a file in c++ 
Cpp :: how to delete a certain amount of numbers of the same value in multiset c++ 
Cpp :: comment in c++ 
Cpp :: how to sort a vector in descending order in c++ 
Cpp :: how to check sqrt of number is integer c++ 
Cpp :: c++ cli convert string to string^ 
Cpp :: string count occurrences c++ 
Cpp :: check if point is left or right of vector 
Cpp :: all of the stars lyrics 
Cpp :: tic toc toe c++ 
Cpp :: sort function from bigest to smallest c++ 
Cpp :: c++ memory leak 
Cpp :: C++ convert integer to digits, as vector 
Cpp :: c++ swapping two numbers 
Cpp :: unordered_map header file c++ 
Cpp :: iff arduino 
Cpp :: use ::begin(WiFiClient, url) 
Cpp :: map in c++ sorted descending order 
Cpp :: max value of double c++ 
Cpp :: c++ vector loop delete 
Cpp :: abs in c++ 
Cpp :: memset in c++ 
Cpp :: prime factorisation of a number in c++ 
Cpp :: arduino funktion 
Cpp :: c++ vector move element to front 
Cpp :: how to use char in c++ 
Cpp :: Count Prefix of a Given String solution leetcode 
Cpp :: remove from vector by value c++ 
Cpp :: print octal number in c++ 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =