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
What is array of structure in c?
What are variables c?
what is the difference between class and unio?
Explain what is the difference between a free-standing and a hosted environment?
Explain how can I make sure that my program is the only one accessing a file?
What is the default value of local and global variables in c?
What is the use of header files?
Is main is user defined function?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
Distinguish between actual and formal arguments.
What is a program?
What is the difference between single charater constant and string constant?
Explain what is the heap?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What is the difference between void main and main in c?