1 | Cents cCents(5); // normal variable |
2 | Cents(7); // anonymous variable |
Cents(7)
will create an anonymous Cents object, initialize it with the value 7, and then destroy it.
1 | Cents cCents(5); // normal variable |
2 | Cents(7); // anonymous variable |
Cents(7)
will create an anonymous Cents object, initialize it with the value 7, and then destroy it.
Wild pointer:
A pointer in c which has not been initialized is known as wild pointer.
Example:
What will be output of following c program?
#include
int main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
return 0;
}
Output:
Any address
Garbage value
Here ptr is wild pointer because it has not been initialized.
There is difference between the NULL pointer and wild pointer. Null pointer points the base address of segment while wild pointer doesn’t point any specific memory location.
NULL is a macro defined in
NUL is the name of the first character in the ASCII character set. It corresponds to a zero value. There?s no standard macro NUL in C, but some people like to define it.
The digit 0 corresponds to a value of 80, decimal. Dont confuse the digit 0 with the value of ?? (NUL)!
NULL can be defined as ((void*)0), NUL as ??.
and NUL is the name of 1st character in the ASCII character set!!