当前位置:网站首页>Array integration initialization (C language)

Array integration initialization (C language)

2022-07-05 08:15:00 chen_ bx

1. Initialize to 0 The size is 13 Array of

#include <stdio.h>

int main()
{
    
	int i;
	int a[13] = {
     0 };
	for (i = 0; i < 13; i++) {
    
		printf("%d\t", a[i]);
	}
}

 Insert picture description here


2. The size is 13 Array of , Initializing page 6 The number is 6 And the 9 First paragraph 10 The number is 9 and 10, The other numbers are 0
Applicable to a large number of 0, Initialization of arrays with only a few values

#include <stdio.h>

int main()
{
    
	int i;
	int a[13] = {
     [5]=6,[8]=9,10 };
	for (i = 0; i < 13; i++) {
    
		printf("%d\t", a[i]);
	}
}

 Insert picture description here

原网站

版权声明
本文为[chen_ bx]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140545026635.html