![]() |
checking str*[] against NULL
When testing if something is NULL does it mean to see if something exists in that memory location, if that is (if not then please do explain) so then why is that am getting an error when i try to see if a struct*[] != NULL. here is the error that i have received.
:
error C2676: binary '!=' : 'HashTable' does not define this operator or a conversion to a type acceptable to the predefined operator:
struct HashTable |
You're getting the error because you haven't defined a != operator for a HashTable (which is what your message says, right?). table [position] is a pointer, but if you dereference it, you're referring to a HashTable. You should test the pointer for NULL before you dereference it.
As for NULL, it's implementation defined. There's a good chance it's zero. Every location in memory has something in it. It's a piece of hardware that has bit cells that can only contain the states, 0 and 1 (except for a short period of time when it's transitioning between the two). There is no "nothing"; there's just an agreement that some "something" will represent "nothing". |
Thanks a bunch Dawei, it worked.
As for the NULL: so instead of checking if its = NULL i can check if it is equal to 0, if so whats the difference between testing if its 0 or NULL; |
Your compiler is required to treat zero as if it's NULL, in a pointer context.
|
| All times are GMT -5. The time now is 1:36 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC