编写strcpy遇到的warning: suggest parentheses around assignment used as truth value [-Wparentheses]|

这是我一开始写的

char *mycat(char *a,const char *b)
{
    int i=0;
    int lena,lenb;
    lena=strlen(a);
    lenb=strlen(b);
    do
    {
        a[lena]=b[i];
        lena++;
        i++;
    }while(i<lenb);
    return a;
}
这是查阅资料后抄的:

char *mystrcat(char *s1,const char *s2){
     char *cp = s1;
        while( *cp )
            cp++;
        while( *cp++ = *s2++ ) ;
    return s1;
}

然而在编译过程中遇到了:warning: suggest parentheses around assignment used as truth value [-Wparentheses]|

在查阅CSDN的文章后,把while(*cp++ = *s2++);的判断语句加上括号就可以了。

感谢:gcc实践(1): warning: suggest parentheses around assignment used as truth value [-Wparentheses]



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
void Sort_CollegeScore(AllCollege *as) //按学院总分排序(直接插入排序) { int i,j,k; printf("\t|----------------------------------------------------------------|\n"); printf("\t|---- 学院编号\t|学院名字 |男团体总分|女团体总分|总分 |----|\n"); printf("\t|----------------------------------------------------------------|\n"); for (i = 2;i<as->College_num;i++) { as->College[0].boys_score = as->College[i].boys_score; as->College[0].girl_score = as->College[i].girl_score; as->College[0].shool_score = as->College[i].shool_score; as->College[0].College = as->College[i].College; strcpy(as->College[0].College_name,as->College[i].College_name); j = i - 1; while (as->College[0].shool_score < as->College[j].shool_score && j >0) { as->College[j+1].boys_score = as->College[j].boys_score; as->College[j+1].girl_score = as->College[j].girl_score; as->College[j+1].shool_score = as->College[j].shool_score; as->College[j+1].College = as->College[j].College; strcpy(as->College[j+1].College_name,as->College[j].College_name); j--; } as->College[j+1].boys_score = as->College[0].boys_score; as->College[j+1].girl_score = as->College[0].girl_score; as->College[j+1].shool_score = as->College[0].shool_score; as->College[j+1].College = as->College[0].College; strcpy(as->College[j+1].College_name,as->College[0].College_name); } for (k = 2;k<=as->College_num;k++) { printf("\t|---- %-9d|%-8s |%-4d\t|%-10d|%-8d|----|\n",as->College[k].College,as->College[k].College_name,as->College[k].boys_score,as->College[k].girl_score,as->College[k].shool_score); printf("\t|----------------------------------------------------------------|\n"); } printf("\n\n");system("pause"); }
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值