-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.c
More file actions
65 lines (52 loc) · 1.15 KB
/
Copy pathmain.c
File metadata and controls
65 lines (52 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
static int
ArraySum(int a,int b ){
return a+b;
}
static void
__char_array_init()
{
const char* cc = "hello";
char cc2[10] = "hello";
char cc3[10] = {"hello"};
char cc4[] = "hello";
char cc5[] = {"hello"};
char cc6[][10] = {"hello", "world"};
}
int
main(int argc, char **argv)
{
char a[5] = {[0] = 'a', [1] = 'b', [3] = 'c', [2] = 'd', [4] = 'e'};
int b[10] = {
[0 ... 1] = 1,
[2 ... 8] = 2,
[9] = 3
};
char c[] = "12345678";
char d[64] = {0};
char e[10] = {'1', '2'};
for (unsigned int idx = 0; idx < 10; idx++) {
printf("%d\t", *(b + idx));
}
printf("\n");
int *p = (int []){
*(b+0)=1,
[1]=(*(b+1)=ArraySum(1,0)),
/*表达式中调用函数*/
[2]=*(b+2)=ArraySum(*(b+1),(*b)),
/*数组值列表中的位置属性[e]可以省略*/
(*(b+3)=(*(b+2)+*(b+1))),
[4]=(*(b+4)=(*(b+3)+*(b+2))),
[5]=(*(b+5)=(*(b+4)+*(b+3))),
[6]=(*(b+6)=(*(b+5)+*(b+4)))
};
for (unsigned int i = 0;i < 7; i++) {
printf("%d\t",*p++);
}
printf("\n");
for (unsigned int idx = 0; idx < 10; idx++) {
printf("%d\t", *(b + idx));
}
printf("\n");
return 0;
}