
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C library macro - NULL()
Description
The C library Macro NULL is the value of a null pointer constant. It may be defined as ((void*)0), 0 or 0L depending on the compiler vendor.
Declaration
Following may be the declaration for NULL Macro depending on the compiler.
#define NULL ((char *)0) or #define NULL 0L or #define NULL 0
Parameters
NA
Return Value
NA
Example
The following example shows the usage of NULL Macro.
#include <stddef.h> #include <stdio.h> int main () { FILE *fp; fp = fopen("file.txt", "r"); if( fp != NULL ) { printf("Opend file file.txt successfully\n"); fclose(fp); } fp = fopen("nofile.txt", "r"); if( fp == NULL ) { printf("Could not open file nofile.txt\n"); } return(0); }
Assuming we have an existing file file.txt but nofile.txt does not exist. Let us compile and run the above program that will produce the following result −
Opend file file.txt successfully Could not open file nofile.txt
stddef_h.htm
Advertisements