hi guys,
i have a variable like this:
may &cfgReg be NULL?Code:ULONG cfgReg=0;
it wont happen usually but in a very extreme situation? if there is no memory for 64bits?
hi guys,
i have a variable like this:
may &cfgReg be NULL?Code:ULONG cfgReg=0;
it wont happen usually but in a very extreme situation? if there is no memory for 64bits?
In this case, taking the address of a declared variable, you should never get a NULL address as the address is either on the stack (if you run out of stack space you have other problems) or in the data section of the code. Memory allocation has nothing to do with it.
Free code: http://sol-biotech.com/code/.
It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up
The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw
> may address of a variable be null
No.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I totally agree with Salem,
Variable decleared cannot be without address.
You can have pointer and initalied to NULL.
like, int *p=NULL;
which would mean the p is a pointer to int but is not pointing to anything .
then can i declare millions billions of variables and run them?
cant system reject your request?
If you've got enough stack space, sure. Otherwise, as long as you have enough ram and/or hard disk(swap) space to keep making variables dynamically, sure. Otherwise you'll run out of memory and malloc will fail and tell you as much.
Quzah.
Hope is the first step on the road to disappointment.