NULL Pointer

Special value that indicates that it is not pointing to any valid reference or memory address.

 

Can be assigned using NULL, 0 or nullptr:

#include <iostream>
using namespace std;

int main () {

	int *xPtr = NULL ;
	int *yPtr = 0 ;
	int *zPtr = nullptr ;

	cout << "Assigned using NULL: " << xPtr << endl ;
	cout << "Assigned using 0: " << yPtr << endl ;
	cout << "Assigned using nullptr: " << zPtr << endl ;

	return 0;
}

Compile & Run:

Assigned using NULL: 0
Assigned using 0: 0
Assigned using nullptr: 0

Leave a Reply