今天去面试一到题 :
在文件 A.C 里定义 char *p="123";在文件 B.C 里声明 extern char p[]; 并打印 printf("the p ===%s\n",p);
运行结果会怎样?
当时为的想法是 编译应该不过 但是底气不足 也没写上去
在gcc 编译了 一下果然报错了:
conflicting types for ‘p’ 大概的意思就是 声明的和定义的不一样
ct@ubuntu:~/Desktop$ gcc -g test1.ctest1.c:3:14: error: conflicting types for ‘p’ extern char *p; ^In file included from test1.c:2:0:test.h:4:6: note: previous definition of ‘p’ was here char p[]="123"; ^
对这三者 再研究看看 记录一下:
前两天稍微看了一下数组和指针: