what is the difference between NULL('\0') and 0?

Answer Posted / salim

I am going to speak in cotext to c language.
NULL is a macro defined in header files such as
stdio.h,stdlib.h,alloc.h,stddef.h,mem.h.The c pre processor
substitutes NULL by the value 0.Its declaration appears to
be like #define NULL 0 in the standard libraries.It is
used to initialise pointers to 0 and helps in portability.
It is a null pointer constant a convention for programmers
to initialise pointers.It is used mainly with pointer.

0 is simply an integer constant.

/0 is a backslash character contant used to indicate end of
string or a string terminator.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In C language, a variable name cannot contain?

747


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

774


What are the advantages of the functions?

610


What are pointers? Why are they used?

633


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

811






Do you know the purpose of 'register' keyword?

647


What are variables c?

626


What is the significance of c program algorithms?

685


What does stand for?

602


Is c a great language, or what?

608


What is the use of gets and puts?

608


Is c call by value?

613


Can you subtract pointers from each other? Why would you?

563


Can you pass an entire structure to functions?

699


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

648