免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2979 | 回复: 2
打印 上一主题 下一主题

[Linux] warning: statement with no effect [-Wunused-value]错误示例 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-11-27 22:07 |只看该作者 |倒序浏览
本帖最后由 pota_xu 于 2016-11-27 22:23 编辑

来源:sinat_28677547http://blog.csdn.net
源:
#include <stdio.h>

int main()
{
    int i;
    int j;
    for(i=0,j=0;i++;i<256)
    {
        if((i%==0)
        {
            
            printf("\n%d:",j);
            j++;
        }
        printf("%c ",i);
    }
    return 0;
}
编译后报错:
~/run$ gcc -Wall -o ascii ascii.c
ascii.c: In function ‘main’:
ascii.c:7:2: warning: statement with no effect [-Wunused-value]
  for(i=0,j=0;i++;i<256)
原因是:for格式用错:修改为: for(i=0,j=0;i<25;i++)后就ok



ascii.zip

294 Bytes, 下载次数: 4

论坛徽章:
0
2 [报告]
发表于 2016-11-27 22:09 |只看该作者
show ver
The program 'show' can be found in the following packages:
* mailutils-mh
* nmh
Try: sudo apt install <selected package>
pota@pota-pc:~/run$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

论坛徽章:
0
3 [报告]
发表于 2016-11-27 22:12 |只看该作者
16位执行结果
pota@pota-pc:~/run$ ./ascii

2:  ! " # $ % & ' ( ) * + , - . /
3:0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 A B C D E F G H I J K L M N O
5 Q R S T U V W X Y Z [ \ ] ^ _
6:` a b c d e f g h i j k l m n o
7:p q r s t u v w x y z { | } ~
8:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
9:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
10:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
11:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
12:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
13:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
14:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
15:▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP