第1个回答 2017-07-21
可以,如下:
polly@nowthen:~/test$ cat test.c
#include <stdio.h>
int main(void)
{
int a=1, b=2, c=3, d=4;
int arr[4] = {a, b, c, d};
int i=0;
for(; i<4; i++) {
printf("arr[%d]=%d\n", i, arr[i]);
}
return 0;
}
polly@nowthen:~/test$ gcc -Wall test.c -o liu
polly@nowthen:~/test$ ./liu
arr[0]=1
arr[1]=2
arr[2]=3
arr[3]=4