C Programming - Pointers - Discussion
Discussion Forum : Pointers - Yes / No Questions (Q.No. 1)
1.
Is there any difference between the following two statements?
char *p=0;
char *t=NULL;
char *p=0;
char *t=NULL;
Answer: Option
Explanation:
NULL is #defined as 0 in the 'stdio.h' file. Thus, both p and t are NULL pointers.
Discussion:
10 comments Page 1 of 1.
Madhu reddy said:
8 years ago
Null we can't print on the screen and we can't give as an input at runtime.
But '0' we can print and giveas an input at runtime.
Obviously, both are different.
But '0' we can print and giveas an input at runtime.
Obviously, both are different.
Diego said:
8 years ago
No,
NULL is defined like this;
#define NULL (*void) 0
not only 0...
NULL is defined like this;
#define NULL (*void) 0
not only 0...
Parag said:
9 years ago
It's yes. The default is NULL.
Krishna said:
1 decade ago
Yes, null=0;
It means empty space.
It means empty space.
Guru prasad said:
1 decade ago
If header stdio.h has been not included means the macro NULL won't work. How both are same?
K.S said:
1 decade ago
Instead of this,
char *p='/0';
char *t=NULL;
printf("%d %d",p,t);
Only got same output?
char *p='/0';
char *t=NULL;
printf("%d %d",p,t);
Only got same output?
Gurchet said:
1 decade ago
int *p=0;
char *t=NULL
printf("%d,%d",p,t);
Output: 0,0
char *t=NULL
printf("%d,%d",p,t);
Output: 0,0
Xcoder said:
1 decade ago
#include<stdio.h>
#include<conio.h>
int main()
{
int *p=0; // why code not compile when *p is other than 0;eg:1,9;in
char *t=NULL;
printf(".....%d",p,t);
getch();
return 0;
}
#include<conio.h>
int main()
{
int *p=0; // why code not compile when *p is other than 0;eg:1,9;in
char *t=NULL;
printf(".....%d",p,t);
getch();
return 0;
}
Pooja said:
1 decade ago
0 is assumed as value not null so I think they both are different. If a variable have a 0 that mean it is not null.
Mini said:
1 decade ago
null is defined by \0 then why 0 and NULL are same?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers