NULL - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# NULL

From cppreference.com
< c‎ | types

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>` |  |
#define NULL /*implementation-defined*/ |  |

Expands into implementation-defined null-pointer constant.

### [edit] Example

Run this code

    #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:

    (none)

### [edit] See also

C++ documentation for NULL

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/types/NULL&oldid=70921"