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;
P is a constant
P is a character constant
P is character type
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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;

Ravi said:   1 decade ago
P is a pointer to a constant.

Because,

Const char *p;.

Rocky said:   1 decade ago
p is constant or p is character constant???
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.

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;

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:

Your comments will be displayed after verification.