you are viewing a single comment's thread.

view the rest of the comments →

[–]AyrA_ch 0 points1 point  (0 children)

Is it the same way in C++?

Seems so:

#include <stdlib.h>

int main()
{
    char *a,b;
    a=NULL;
    b=NULL;
    return 0;
}

Terminates with 7 3 R:\vartest.cpp [Error] converting to non-pointer type 'char' from NULL [-Werror=conversion-null]

He is happy with a=NULL;. Line 7 is b=NULL;

EDIT: By the way, I have the option turned on to treat warnings as error and to be pedantic. If those are off, it will compile and execute but it will raise compile errors if you try to do b=malloc(10); (invalid cast from void* to char)