<分区>
Possible Duplicates:
How to initialize an array to something in C without a loop?
How to initialize an array in C
如何在不使用 for 或任何其他循环的情况下将已知大小的数组归零?
例如:
arr[20] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
这是很长的路...我需要它的捷径。
<分区>
Possible Duplicates:
How to initialize an array to something in C without a loop?
How to initialize an array in C
如何在不使用 for 或任何其他循环的情况下将已知大小的数组归零?
例如:
arr[20] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
这是很长的路...我需要它的捷径。
最佳答案
int arr[20] = {0};
C99 [$6.7.8/21]
If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.
关于c - C代码中的数组归零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5636070/