S
sugaray
I wrote a short code as shown below for experiment purpose,
It is successfully compilable, yet I found the piece I wrote
even confused myself with the consts and the asterisks, and
which brought up three questions to me:
1) will the casting in line 1 affect the rest of the
declarations ?
2) what's the difference between line 2 and line 3
3) are there any practical purposes of the usage of any
of the three ?
#include <stdio.h>
int main(int argc,char **argv)
{
const char **pa=(const char **)argv; // line 1
const char *const *p=argv; // line 2
const char *const *const pp=argv; // line 3
printf("%s %c\n",*++p,**p);
printf("%s %c\n",*pp,**pp);
return 0;
}
It is successfully compilable, yet I found the piece I wrote
even confused myself with the consts and the asterisks, and
which brought up three questions to me:
1) will the casting in line 1 affect the rest of the
declarations ?
2) what's the difference between line 2 and line 3
3) are there any practical purposes of the usage of any
of the three ?
#include <stdio.h>
int main(int argc,char **argv)
{
const char **pa=(const char **)argv; // line 1
const char *const *p=argv; // line 2
const char *const *const pp=argv; // line 3
printf("%s %c\n",*++p,**p);
printf("%s %c\n",*pp,**pp);
return 0;
}