常量对参数数组的大小EX pressions [英] const for array size expressions on argument

查看:131
本文介绍了常量对参数数组的大小EX pressions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的C code例如:

  INT F(const int的farg [常量5])
{
}

什么是对数组的大小额外的常量呢?不同的是什么时,我省略了常量呢?


解决方案

  INT D(const int的DARG [5])

平均值 DARG 是一个指向常量 INT

  INT E(INT EARG [常量5])

平均值 EARG 常量指针 INT 。这是C99的功能。 TA [预选赛名单E] 相当于为 T *预选赛名单A 参数声明。

当然,(上面):

  INT F(const int的farg [常量5])

平均值 farg 常量指针常量 INT

I have the following C code example:

int f(const int farg[const 5])
{
}

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])

Means darg is a pointer to const int.

int e(int earg[const 5])

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.

And of course (from above):

int f(const int farg[const 5])

Means farg is a const pointer to const int.

这篇关于常量对参数数组的大小EX pressions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆