A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Making a valid pointer as NULL pointer in C
Q:

Making a valid pointer as NULL pointer in C

0

Making a valid pointer as NULL pointer in C

Example:

Here, firstly ptr is initialized by the address of num, so it is not a NULL pointer, after that, we are assigning 0 to the ptr, and then it will become a NULL pointer.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include <stdio.h>

int main(void) {
	int num = 10;
	int *ptr = &num;
	
	//we can also check with 0 instesd of NULL 
	if(ptr == NULL)
		printf("ptr: NULL\n");
	else
		printf("ptr: NOT NULL\n");

	//assigning 0 
	ptr = 0;
	if(ptr == NULL)
		printf("ptr: NULL\n");
	else
		printf("ptr: NOT NULL\n");

	return 0;
}

Output

ptr: NOT NULL
ptr: NULL

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now