- 论坛徽章:
- 0
|
#include <stdio.h>
int main(void)
{
const char *mytal[5] = {
"Adding numbers swiftly",
"Multiplying accurately",
"Stashing data",
"Following instructions to the letter",
"Understanding the C language"
};
// printf("%s\n",mytal[1]); // Q: 为什么打开注释后会报错
const char ** pt = mytal;
printf("%s\n",*(pt + 1));
return 0;
}
附:
1. VC下报错信息:
--------------------Configuration: cStudy - Win32 Debug--------------------
Compiling...
test.c
D:\Program Files\Microsoft Visual Studio\MyProjects\cStudy\test.c(14) : error C2143: syntax error : missing ';' before 'const'
D:\Program Files\Microsoft Visual Studio\MyProjects\cStudy\test.c(15) : error C2065: 'pt' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\cStudy\test.c(15) : error C2100: illegal indirection
Error executing cl.exe.
test.obj - 3 error(s), 0 warning(s)
2. linux 正常:
[root@tomsui root]# cc -dumpversion
3.2.3
[root@tomsui root]# cc test.c
[root@tomsui root]# ./a.out
Multiplying accurately
Multiplying accurately
[root@tomsui root]#
指点12,不胜感激。多谢先。 |
|