所以它似乎意味着a pointer to a constant pointer to char。那就是它指向 a char * const,到目前为止一切顺利。
让我感到困惑的是我在哪里以及如何看到它使用的。我正在查看手册页,qsort示例执行以下操作以将指向 a char **(字符串数组)的元素的指针(指向被视为 的元素的指针const void *)转换为可提供给的普通 char 指针strcmp:
static int
cmpstringp(const void *p1, const void *p2)
{
/* The actual arguments to this function are "pointers to
pointers to char", but strcmp(3) arguments are "pointers
to char", hence the following cast plus dereference */
return strcmp(* (char * const *) p1, * (char * const *) p2);
}
我的问题是,为什么会有演员表char * const *?为什么它不只是 a const char **(因为最终我们想发送 a const char *to strcmp)?