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

Expands into implementation-defined null-pointer constant.

Example

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

See also

C++ documentation for NULL
doc_C_Language
2016-10-10 18:35:58
Comments
Leave a Comment

Please login to continue.