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
Describe the header file and its usage in c programming?
What is volatile keyword in c?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
How many types of errors are there in c language? Explain
Explain union. What are its advantages?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What is meant by high-order and low-order bytes?
What is sizeof array?
Explain how can I make sure that my program is the only one accessing a file?
What is the difference between the local variable and global variable in c?
What is static and auto variables in c?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
Why can’t we compare structures?
How to write a multi-statement macro?
What is the advantage of an array over individual variables?