[英]Confusion about const syntax
I'm having some trouble reading a line in a program that looks like this: 我在读取如下所示的程序中的一行时遇到了一些麻烦:
char* const *(*next) ();
I think next
is a pointer to a function returning a pointer to a const
pointer to a char
, but I'm still a bit confused. 我认为
next
是指向函数的指针,该函数返回指向char
的const
指针的指针,但我仍然有些困惑。 If someone could answer this ASAP that would be great! 如果有人可以尽快回答这个问题,那就太好了!
cdecl可以帮助您了解C语言中更复杂的声明。
char* const* (*next) ();
You are declaring a function pointer called next
that returns a char* const*
(pointer to a char* const
). 您正在声明一个名为
next
的函数指针,该函数指针返回一个char* const*
(指向char* const
指针)。 You were right (: 你是对的 (:
Usage : 用法:
char* const* ret = next();
or char* const* ret = (*next)();
或
char* const* ret = (*next)();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.