Null Pointer Assignment in C | Null Pointer concept in c
It does make sense to assign an integer value to a pointer variable.
An exception is an assignment of 0, which is sometimes used to indicate
some special condition(Null pointer).
A macro is used to represent a null pointer. That macro goes under
the name NULL. Thus, setting the value of a pointer using the NULL, as
with an assignment statement such as ptr = NULL, tells that the pointer
has become a null pointer. Similarly, as one can test the condition for
an integer value as zero or not, like if (i == 0), as well we can test
the condition for a null pointer using if (ptr == NULL) or you can even
set a pointer to NULL to indicate that it’s no longer in use.
# include
# define NULL 0
main()
{
int *pi = NULL;
printf(“The value of pi is %u”, pi);
}
Related Links :
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
getch ();
}
No comments:
Post a Comment