I sometimes see coders that use NULL as return value of main() in C and C++ programs, for example something like that:
#include <stdio.h>
int main()
{
    printf("HelloWorld!");
    return NULL;
} 
When I compile this `code with gcc I get the warning of:
warning: return makes integer from pointer without a cast [-Wint-conversion]
which is reasonable because the macro NULL shall be expanded to (void*) 0 and the return value of main shall be of type int.
When I make a short C++ program of:
#include <iostream>
using namespace std;
int main()
{
    cout << "HelloWorld!";
    return NULL;
}
And compile it with g++, I do get an equivalent warning:
warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
But why do they use NULL as return value of main() when it throws a warning? Is it just bad coding style?
- What is the reason to use NULLinstead of0as return value ofmain()despite the warning?
- Is it implementation-defined if this is appropriate or not and if so why shall any implementation would want to get a pointer value back?
 
     
     
     
     
    