null pointer is pointer pointing to an undefined space etc
http://en.wikipedia.org/wiki/Null
that's funny cause that's not what that link you provided says, it rather makes a difference between a NULL pointer and an uninitialized pointer, which is what you just described.hgoel0974 wrote:null pointer is pointer pointing to an undefined space etc
well my bad, that's what I thought I read but anyway, technically a null pointer points to 0, right?Acid_Snake wrote:that's funny cause that's not what that link you provided says, it rather makes a difference between a NULL pointer and an uninitialized pointer, which is what you just described.hgoel0974 wrote:null pointer is pointer pointing to an undefined space etc
The way I see it is that NULL means it's not pointing to anything (hence the name), while void is undefined, it could be pointing to a valid (albait random) area or it could be some other random thing which could cause a crash or malfunction, this is why we always initialize pointers to NULL, to prevent this random behaviour.codestation wrote:Depends on the implementation. In some obscure platforms null isn't zero and the address at 0 is a valid address.
The important thing is that neither C or C++ has tied NULL to 0 (as physical address).
Code: Select all
int *foo = 0;
Code: Select all
int *foo = NULL;
I think it's in sdtio or stdlib, you have something like thiscodestation wrote:Also, i cannot remember the source but i read that internally the C compiler will replace 0 with the internal representation of the NULL pointer for that platform when is assigned to a pointer type
Code: Select all
#ifdef GCC
#define NULL 0x0
#else
#define NULL 0
#endif
there's no such thing as a null character, internally what you place at the end of a string is 0x00, which is not as different as NULL being 0x0codestation wrote:For strings is different since one uses a nul character instead of a NULL pointer.
This is getting weird; but the topic title is "programming dictionary", not computer dictionary, I have no idea, and honestly no need to know how 0 or NULL is being stored in C or Python; But In my opinion, stating that NULL = 0, is wrong;Acid_Snake wrote:You are looking at this definition from a high level perspective, which is ALWAYS the wrong way to look at computers, or every other mathematical or physical form. As I explained before, in semantics, mathematics AND computing, NULL == 0, I don't care what Javascript tells you, JavaScript is high level, so it separates itself from everything related to what a computer really is and gives you a false feeling of what a computer is and how it works. To give you a better view of why JavaScript's Null can't really be considered "null" in itself, take a look at python's version of Null and how it really works at low level, you will then see that JavaScript's Null != the mathematical, semantc and computing definition of Null.
I'm gonna revert you to what I previously said:svenn wrote:unless you have constants defined, would not work.
point being that NULL == 0, but some compilers parse stuff like "int i = NULL + 1" to make them invalid, still you should at least do some research before posting, NULL == 0, both in semantics, maths and programming.Acid_Snake wrote:I think it's in sdtio or stdlib, you have something like this
Code: Select all
#ifdef GCC #define NULL 0x0 #else #define NULL 0 #endif
ot something like that
Code: Select all
#include <stdio.h>
int main() {
int *foo = NULL;
int *bar = 0;
printf("Hello wololo\n");
return 0;
}
Code: Select all
...
int main() {
int *foo = ((void *)0);
int *bar = 0;
printf("Hello wololo\n");
return 0;
}
Code: Select all
...
int main() {
int *foo = __null;
int *bar = 0;
printf("Hello wololo\n");
return 0;
}