Which one of the following represents a correct and safe declaration of NULL ?

A) typedef((void *)0) NULL;
b) typedef NULL(char *)0;
c) #define NULL((void *)0)
d) #define NULL((char*)0)
This question is related to BirlaSoft Interview

Showing Answers 1 - 7 of 7 Answers

Ranjit

  • Apr 25th, 2005
 

option b is correct answer

  Was this answer useful?  Yes

pallavi

  • Jul 23rd, 2005
 

#define NULL((void *)0)

vivek

  • Mar 6th, 2007
 

NULL is a character, so how can it be declared as a macro with data type as void ?
please reply if you know the exact explanation to your point
waiting for your reply!

  Was this answer useful?  Yes

Shrishail

  • Jul 23rd, 2007
 

typedef((void *)0) NULL; can also be the correct one since NULL is a value that is assigned to pointers. The above declaration shall be good for generic data types.

Sabik

  • Aug 17th, 2007
 

#define NULL 0 is enough. NULL should be used as pointer. To be on the safer side, so that NULL wont be used as constant 0, we define #define NULL((void *)0). Then if we assign int x =NULL, it would give a compilation error

  Was this answer useful?  Yes

Gunjan Shaw

  • Mar 3rd, 2016
 

d) #define NULL((char*)0)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions