K
Krishna
I have three typedefs are defined below.
typedef char* PCHAR;
typedef const PCHAR PCCHAR1;
typedef const char* PCCHAR2;
In a piece of code, these typedef's are used as follows.
PCCHAR1 pc1 = text;
pc1 = text + 1;
PCCHAR2 pc2 = text;
pc2 = text + 1;
Now assigning a value to pc1 gives a compile error, while assigning a value
to pc2 doesn't give a compile error. The difference between the declaration
of PCCHAR1 and PCCHAR2 is that i have substituted "PCHAR" with "char*". I
had all along guessed that a typedef can be understood by just substituting.
Can someone please clear up my confusion?
Thanks & Regards,
Krishna
typedef char* PCHAR;
typedef const PCHAR PCCHAR1;
typedef const char* PCCHAR2;
In a piece of code, these typedef's are used as follows.
PCCHAR1 pc1 = text;
pc1 = text + 1;
PCCHAR2 pc2 = text;
pc2 = text + 1;
Now assigning a value to pc1 gives a compile error, while assigning a value
to pc2 doesn't give a compile error. The difference between the declaration
of PCCHAR1 and PCCHAR2 is that i have substituted "PCHAR" with "char*". I
had all along guessed that a typedef can be understood by just substituting.
Can someone please clear up my confusion?
Thanks & Regards,
Krishna