为什么声明仅包含C中的数组结构? [英] Why declare a struct that only contains an array in C?

查看:104
本文介绍了为什么声明仅包含C中的数组结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到包含以下一些code来了:

I came across some code containing the following:

struct ABC {
    unsigned long array[MAX];
} abc;

在是否有意义使用的声明这样吗?

When does it make sense to use a declaration like this?

推荐答案

它可以让你按值传递数组给一个函数,或者把它从一个函数返回值由

It allows you to pass the array to a function by value, or get it returned by value from a function.

结构可以按值传递,不像数组这衰减到在这些上下文的指针。

Structs can be passed by value, unlike arrays which decay to a pointer in these contexts.

这篇关于为什么声明仅包含C中的数组结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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