What is a NULL pointer in C

2 Answers

0 votes
// NULL pointer is a pointer pointing to nothing 

#include <stdio.h> 
 
// #define NULL 0 in stdio.h
 
int main(int argc, char **argv) 
{ 
    int *p = NULL;
    
    printf("%p",p); // A pointer that point to nothing.
    
    return(0);
}

 
 
/*
 
run:
 
0000000000000000
 
*/

 



answered May 5, 2017 by avibootz
edited Jun 21, 2017 by avibootz
0 votes
// NULL pointer is a pointer pointing to nothing 
 
#include <stdio.h>
 
int main(void)
{
    int *p1 = NULL;
     
    printf("p1 = %p\n", p1); 
     
    int *p2 = '\0';
     
    printf("p2 = %p\n", p2); 
     
    return 0;
}
 
   
/*
run:
     
p1 = 0000000000000000
p2 = 0000000000000000
 
*/

 



answered Jun 21, 2017 by avibootz

Related questions

2 answers 253 views
1 answer 132 views
1 answer 124 views
124 views asked May 13, 2021 by avibootz
1 answer 152 views
152 views asked Jun 21, 2017 by avibootz
1 answer 271 views
271 views asked Jun 20, 2017 by avibootz
1 answer 174 views
174 views asked May 5, 2017 by avibootz
...