|
From: KOFKS on 21 Feb 2006 02:02 I come acorss a question about NULL, so I write a piece to verify my opinion, but I'm cofused at the result.(Under dev-c++4.9.9.2, and I have not tried other compiler.) ********************************************************************** #include <iostream> using namespace std; int main() { void *p; p = '\0'; if (NULL == p) cout << " After \"p = \'\\0\';\" p is NULL " << endl; p = 0; if (NULL == p) cout << " After \"p = 0;\" p is NULL " << endl; p = (void *)EOF; //if remove (void*), compiler reports "invalid conversion from 'int' to 'void'. if (NULL == p) cout << " After \"p = (void *)EOF;\" p is NULL " << endl; p = NULL; if (NULL == p) cout << " After \"p = NULL;\" p is NULL " << endl; system("pause"); return 0; } *********************************************************************** The output is : *********************************************************************** After "p = '\0';" p is NULL After "p = 0;" p is NULL After "p = NULL;" p is NULL *********************************************************************** So why? I used to believe EOF is NULL, however it seems wrong.
|
Pages: 1 Prev: Passing reference through void pointer Next: Call by reference |