数组初始化 C [英] Array initialization C

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

问题描述

这个初始化是什么意思:

What is the meaning of this initialization:

char arr[10] = { 0, };

我熟悉 char arr[10] = {0}; 它将所有元素设置为零,以及 char arr[10] = {1,2}; 它将前两个元素设置为 1 和 2 (ascii),其余元素设置为 0.我不熟悉上面的格式.快速测试表明它可能就像 char arr[10] = {0};,但还有其他我不知道的含义吗?

I'm familiar with char arr[10] = {0}; which sets all the elements to zero, and with char arr[10] = {1,2}; which sets the first two elements to 1 and 2 (ascii) and the rest to 0. I'm not familiar with the format above. A quick test showed that it's probably just like char arr[10] = {0};, but is there other meaning I'm not aware of?

推荐答案

是的,相当于没有尾随逗号的版本.

Yes, it's equivalent with the version without the trailing comma.

请参阅此问题,了解有关尾随逗号的更多讨论.

See this question for more discussion about trailing commas.

这篇关于数组初始化 C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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