关于 const 语法的困惑
我在读取程序中的一行时遇到一些问题,如下所示:
char* const *(*next) ();
我认为 next
是一个指向函数的指针,该函数返回一个指向 const
指针的指针,该指针指向 < code>char,但我还是有点困惑。如果有人能尽快回答这个问题那就太好了!
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. If someone could answer this ASAP that would be great!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cdecl可以帮助你理解C中更复杂的声明。
cdecl can help you understand the more complicated declarations in C.
char* const* (*next) ();
您正在声明一个名为
next
的函数指针,它返回一个char* const*
(指向一个char* const
)。你是对的(:用法:
char* const* ret = next();
或char* const* ret = (*next)();
char* const* (*next) ();
You are declaring a function pointer called
next
that returns achar* const*
(pointer to achar* const
). You were right (:Usage :
char* const* ret = next();
orchar* const* ret = (*next)();