24小时热门版块排行榜    

查看: 1358  |  回复: 7
本帖产生 1 个 程序强帖 ,点击这里进行查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

gd88

金虫 (小有名气)


zyj8119(金币+10):谢谢您精彩的回复!!!! 2010-11-03 07:21:37
nono2009(金币+1, 程序强帖+1):鼓励应助 2010-11-11 07:31:20
从目前的编译信息来看:
warning: #warning This file includes at least one deprecated or antiquated header.
你这段代码包含了不赞成的或者是老标准的文件头,

Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard.
参看 C++ Standard 的 17.4.1.2 (我看了,里面没有 .h )

Examples include substituting the header for the header for C++ includes, or instead of the deprecated header .
用<******>代替<******.h>(把.h去掉),
或者用代替

To disable this warning use -Wno-deprecated.

编译器版本的问题,目前的信息看来。
根据编译的信息作修改先,不行的话去看 C++ standard 的 17.4.1.2 部分的内容。
再不行的话,帖出编译信息。

---------------------------另:
刚才我在虚拟机里装了个WinGW 2.05,
重现了你的代码错误,
C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.

去掉     .h     后,
反正上面重现的这段编译错误没有了。

-----------------------------
哎,查了查,试了试,
编译器的问题,或者说标准的问题。
你试下这段代码把,我这里仅仅是编译通过了。  revised    是修改的地方。
为什么这么修改,我也是根据你的编译信息,google了一下而已。
要符合你的程序需求,可能还要调一下。

编译器之间的问题还是要重视的。
CODE:
#include /*revised*/
#include /*revised*/
struct STRU
{     char s1[5],s2[5];
      int a,b;
};

char *str_num(int n)
{    int k=0,m=n,i=0;
     while(m){k++;m/=10;}
         char *str=new char[k+1];
         while(n){
                 str[k-i-1]=n%10+'0';
                 n/=10;i++;
         }
         str[i]='\0';
         return str;
}

char *fun(STRU *p1,int n)
{   int k=0;
    for(int i=0;i                 k+=strlen(p1[i].s1)+strlen(p1[i].s2);
                int t1=p1[i].a,t2=p1[i].b;
                while(t1){k++;t1/=10;}
                while(t2){k++;t2/=10;}
        }
        char *p2=new char[k+1];
        strcpy(p2," ");
        for(int i=0;i                 strcat(p2,p1[i].s1);
                strcat(p2,p1[i].s2);
                char *temp=str_num(p1[i].a);
                strcat(p2,temp);
                delete []temp;
                temp=str_num(p1[i].b);
                strcat(p2,temp);
                delete []temp;
                temp=0;
        }
        return p2;
}

int main() /*revised*/
{    STRU st[2]={"AAA","BBB",234,1535,"CCCC","DDDD",9559,453};
     char *p=fun(st,2);
         std::cout<          delete []p;
         return 0; /*revised*/
}

[ Last edited by gd88 on 2010-11-3 at 04:47 ]
2楼2010-11-03 03:05:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见