How to stop a program in compile time when a pointer is null in C

1 Answer

0 votes
#include <stdio.h>
#include <assert.h>

int main()
{
    char* p = NULL;

    assert(p);

    return 0;
}



/*
run:

Assertion failed: p, file C:\src\main.c, line 8

*/

 



answered Jul 31, 2024 by avibootz
...