C Programming - Typedef - Discussion
Discussion Forum : Typedef - General Questions (Q.No. 2)
2.
In the following code what is 'P'?
typedef char *charp;
const charp P;
Discussion:
36 comments Page 3 of 4.
Asd said:
1 decade ago
I think finally answer is p is a pointer to a character constant which is not in option so anwer is d.
Ganga said:
1 decade ago
const char *P; // The value can not be changed at that memory location, but other memory locations can be used for *P.
*P=4; //ERROR
P=&a; //Works char a;
*P=4; //ERROR
P=&a; //Works char a;
Ravi said:
1 decade ago
P is a pointer to a constant.
Because,
Const char *p;.
Because,
Const char *p;.
Rocky said:
1 decade ago
p is constant or p is character constant???
please answer!!!!
please answer!!!!
LOL said:
1 decade ago
The trick with const modifier is to read the statement backwards.
const charp P = const char *P;
So reading backwards you have P * char const
which is P is a pointer to a char constant.
const charp P = const char *P;
So reading backwards you have P * char const
which is P is a pointer to a char constant.
Wikiok said:
1 decade ago
typedef char *charp;
const charp P;
so:
const char *P; // The value can not be changed at that memory location, but other memory locations can be used for *P.
*P=4; //ERROR
P=&a; //Works char a;
const charp P;
so:
const char *P; // The value can not be changed at that memory location, but other memory locations can be used for *P.
*P=4; //ERROR
P=&a; //Works char a;
Ana said:
1 decade ago
The answer is no clear to me. Can some one please explain.
Vikas Sharma said:
1 decade ago
P is a constant pointer.
Hngn said:
1 decade ago
p is constant chracter pointer
Santhosh said:
1 decade ago
her p is a pointer to a constant character
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers