首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

switch的case 0 . 4:在GCC中编译成功,在VC 7.1编译失败。解决方法

2012-02-11 
switch的case 0 ... 4:在GCC中编译成功,在VC 7.1编译失败。switch的case0...4:在GCC中编译成功,在VC7.1编译

switch的case 0 ... 4:在GCC中编译成功,在VC 7.1编译失败。
switch的case   0   ...   4:在GCC中编译成功,在VC   7.1编译失败。
//处理case   N:在一个区间的值时,可用case   开始值   ...   结束值:句法。
#include   <iostream>
int   main()
{
        using   namespace   std;
        cout   < <   "switch   test,please   input   number   0   to   9\n ";
        int   n;
        while   (cin   > >   n)
        {
                switch   (n)
                {
                case   0   ...   4:
                                cout   < <   "n   is   between   0   and   4.\n ";
                break;
                        case   6   ...   9:
                                cout   < <   "n   is   between   5   and   9.\n ";
                                break;
                default:
                                cout   < <   "n   is   out   of   [0,9].\n ";
                break;
                }

        }

        system( "PAUSE ");
        return   0;
}
难道的GCC编译器的特殊支持。

[解决办法]
貌似是 gcc 扩展, C99 也没见这种语法 ...
[解决办法]
-pedantic-error
[解决办法]
gcc对c的扩展,没什么好说的
[解决办法]
GCC extension. Refer to GCC Manual (available in "info " pages or online) for more details on language standards compliants and extensions.

热点排行