const 用于参数上的数组大小表达式 [英] const for array size expressions on argument
本文介绍了const 用于参数上的数组大小表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下 C 代码示例:
I have the following C code example:
int f(const int farg[const 5])
{
}
数组大小的附加常量有什么作用?当我在那里省略 const 时有什么区别?
What does the additional const for the array size do? And what is the difference when I omit the const there?
推荐答案
int d(const int darg[5])
表示 darg
是指向 const
int
的指针.
Means darg
is a pointer to const
int
.
int e(int earg[const 5])
表示 earg
是一个 const
指向 int
的指针.这是 c99 的特性.T A[qualifier-list e]
等价于参数声明中的T * qualifier-list A
.
Means earg
is a const
pointer to int
. This is a c99 feature. T A[qualifier-list e]
is equivalent as T * qualifier-list A
in the parameter declaration.
当然(从上面):
int f(const int farg[const 5])
表示 farg
是一个 const
指向 const
int
的指针.
Means farg
is a const
pointer to const
int
.
这篇关于const 用于参数上的数组大小表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文