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

Answer Posted / 111

What is the difference b/w '\0' and NULL?

The first is the representation for the null character, i.e.,
a character with value zero. It is used as a string
terminator in C.
It is actually an "escape sequence" with an octal zero.

The second is a macro that resolves to a null pointer value.
In C source
code a literal zero is also converted into a null pointer
constant when
it occurs in a pointer context.

The first expression is of type int while the second is of a
pointer
type.

> In which case It is useful?

Use '\0' to terminate strings and NULL to initialise
pointers and set
them to a "safe" value after they have been used.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How pointer is different from array?

585


simple program of graphics and their output display

1471


How can I manipulate individual bits?

611


Do array subscripts always start with zero?

788


What is 1f in c?

1845






When should you not use a type cast?

662


Are c and c++ the same?

629


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1216


What is an arrays?

659


How to declare a variable?

575


What is the difference between abs() and fabs() functions?

611


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

707


I have a varargs function which accepts a float parameter?

583


What does 2n 4c mean?

725


What is the use of a conditional inclusion statement in C?

607