C Programming - Typedef - Discussion
Discussion Forum : Typedef - General Questions (Q.No. 1)
1.
In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;
Discussion:
36 comments Page 2 of 4.
Nishant said:
1 decade ago
ptr is the pointer which has the address at which value is stored.And p2 is defined as ptr so p2 is the integer pointer which has the address at which has integer value...
RAJU said:
1 decade ago
Ptr is pointer to integer. Because p1 and p2 are declared as ptr and ptr is pointer to integer, p1 and p2 both will get the same functionality like integer pointer.
Martin said:
1 decade ago
C is case sensitive and the question clearly asks what P2 is. There is no P2. There is a p2, but that is not the same. Therefore, the answer is D.
Prasanth said:
8 years ago
Can we say like this?
*ptr is the name used instead of int and
ptr defines the variables as p1 and p2.
but how to compare the both *ptr and ptr.
*ptr is the name used instead of int and
ptr defines the variables as p1 and p2.
but how to compare the both *ptr and ptr.
Vineet said:
1 decade ago
typedef int *ptr;
Tt means ptr can be used in place of (int *), it is a alais name.
Where we write ptr it means we can substitute it with int *;
Tt means ptr can be used in place of (int *), it is a alais name.
Where we write ptr it means we can substitute it with int *;
Prasad said:
1 decade ago
*ptr is pointer varible, but when you assign p1 and p2 than p1 is hold the address of ptr but p2 is hold address of p1 ? please answer to me.
Nikky Aaryan said:
1 decade ago
*ptr is address of the variables and p1 & p2 are the integers.
int *ptr is nothing but the 'address of the variables are integers'.
int *ptr is nothing but the 'address of the variables are integers'.
Parin said:
1 decade ago
Understand the question like this,
typedef (int *) ptr;
ptr p1,p2;
Now it is very clear that p1 and p2 are integer pointers..
typedef (int *) ptr;
ptr p1,p2;
Now it is very clear that p1 and p2 are integer pointers..
(1)
Lordy said:
1 decade ago
@sunil
p1 is just a pointer. it is not declared as int so how can that be integer. think u will understand clearly.
p1 is just a pointer. it is not declared as int so how can that be integer. think u will understand clearly.
Vengatraman said:
1 decade ago
Becoz p1, p2 s assigned as ptr var & ptr is defined as integer. So I think as it is integer pointer.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers