zoukankan      html  css  js  c++  java
  • VS2005编译C语言程序

    用VS2005编译如下代码:

    void main()

    {

    printf("Hello World!");
    int a; 

    scanf("%d",&a);

    这样会报错:error C2143: syntax error : missing ';' before 'type'

    vs2005和eclipse的区别在于eclipse可以通过。

    void main()
    {
    int a;
    printf("Hello World!");

    scanf("%d",&a);

    只要把int a; 放到第一行就可以编译通过了。

    网上查了下,原因如下:

    "microsoft C compiler wants all variables declared at top of function",

    This is what C89 defines. C99 allows variable declarations also in the middle of a function.

    The problem is you are using a C file. This means the compiler implements strict C rules. If you change your source file to a cpp type file, you will use the C++ compiler which is myuch more flexible

  • 相关阅读:
    在列表中添加序号列
    在C#中使用正则表达式
    Git
    Linux 配置Java环境
    讯飞语义理解 JAVA SDK
    分屏显示
    Gdiplus
    重启进程
    MFC 常用功能属性
    MFC 打印
  • 原文地址:https://www.cnblogs.com/lionfight/p/2603873.html
Copyright © 2011-2022 走看看