top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What happens when we try to access null pointer in C?

+1 vote
118 views
What happens when we try to access null pointer in C?
posted Jan 22, 2015 by Balu

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Most of the CPUs support virtual memory, a page fault exception will be usually issued if you try to read at memory address 0x0 i.e. NULL . The OS page fault handler will be invoked, the OS will then decide that the page is invalid and aborts your program.

answer Jan 22, 2015 by Salil Agrawal
0 votes

NULL pointer is pointer that is pointing to nothing (No memory location). Accessing null pointer in C may lead a program to crash. So, Null pointer should not be accessed in a program.

answer Jan 23, 2015 by Shivaranjini
...