我的一个cpp文件内容如下:main () [
double p[2] = {5.0, 9.0};
printf("It is %f",p[1]);
int i;
}运行后给出下面的错误信息:
Compiling...
text.cpp
c:\documents and settings\administrator\桌面\x\text.cpp(2) : error C2144: syntax error : missing ']' before type 'double'
c:\documents and settings\administrator\桌面\x\text.cpp(2) : error C2090: function returns array
c:\documents and settings\administrator\桌面\x\text.cpp(2) : error C2144: syntax error : missing ';' before type 'double'
c:\documents and settings\administrator\桌面\x\text.cpp(2) : error C2501: 'main' : missing storage-class or type specifiers
c:\documents and settings\administrator\桌面\x\text.cpp(2) : fatal error C1004: unexpected end of file found
Error executing cl.exe.text.exe - 5 error(s), 0 warning(s)我无法检查出哪里出错了,请帮忙。谢谢!

解决方案 »

  1.   

    main () [
    笔误?
      

  2.   

    main () ["["  错了。
      

  3.   

    main()  前面缺少返回类型  
      

  4.   

    #include <stdio.h>,连double类型都找不到
      

  5.   

    main () [color=#FF0000][[/color]double p[2] = {5.0, 9.0};
    printf("It is %f",p[1]);
    int i;
    }很明显  怎么会找不到错误呢  注意头文件不要让他去睡觉
      

  6.   

    main()
    大神!
      

  7.   

    #include <stdio.h>void main () {
    double p[2] = {5.0, 9.0};
    printf("It is %f",p[1]);
    }
      

  8.   

    missing ']' before type 'double'main () [这里有笔误啊~~~
      

  9.   

    呵呵main()身后的 花括号{ 你写成了[