001、
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ##测试c程序 #include <stdio.h> int main(void) { int i,j; i = j = 5; // 连续赋值 printf("i = %d\n", i); printf("j = %d\n", j); return 0; } [root@PC1 test]# gcc test.c -o kkk [root@PC1 test]# ls kkk test.c [root@PC1 test]# ./kkk i = 5 j = 5
002、
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int main(void) { int i = j = 5; // 无法再初始化过程中连续赋值 printf("i = %d\n", i); printf("j = %d\n", j); return 0; } [root@PC1 test]# gcc test.c -o kkk test.c: In function ‘main’: test.c:5:10: error: ‘j’ undeclared (first use in this function) int i = j = 5; ^ test.c:5:10: note: each undeclared identifier is reported only once for each function it appears in
003、
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int array1[3] = {1,3,4}; // 数组可以连续赋值初始化 return 0; } [root@PC1 test]# gcc test.c -o kkk ## 编译 [root@PC1 test]# ls kkk test.c
004、
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int array[3]; array[3] = {1,3,8}; //数组中不可以这样连续赋值 return 0; } [root@PC1 test]# gcc test.c -o kkk ## 无法编译 test.c: In function ‘main’: test.c:7:13: error: expected expression before ‘{’ token array[3] = {1,3,8}; ^
。
标签:语言,int,PC1,ls,kkk,test,赋值,root,变量 From: https://www.cnblogs.com/liujiaxin2018/p/18530886