开发者

C statement const meanings

In the code below, what do the first and second const mean?

I guess first or second means foo is constant; the other one means elements of foo are also constants. Is it true?

static const char * const foo[] = {"开发者_如何学编程bar", "baz"};


It means its an array of const pointers (so you can't change the pointers) to const chars (so you can't change the chars via the pointers). This is a common way of defining fixed strings, such as command names, in an application.


See cdecl:

declare foo as array of const pointer to const char

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜