NULL

Defined in header <stddef.h>
Defined in header <string.h>
Defined in header <wchar.h>
Defined in header <time.h>
Defined in header <locale.h>
Defined in header <stdio.h>
1
#define NULL /*implementation-defined*/

Expands into implementation-defined null-pointer constant.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdlib.h>
  
struct S;
void(*f)() = NULL;
  
int main(void)
{   
    char *ptr = malloc(sizeof(char)*10);
    if (ptr == NULL) exit(EXIT_FAILURE);
    free(ptr);
    ptr = NULL;
  
    int* p = NULL;
    struct S *s = NULL;
  
    return EXIT_SUCCESS;
}

Possible output:

1
(none)

See also

C++ documentation for NULL
doc_C_Language
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.