c语言中后置递增运算符和前置递增运算符的区别

 

001、

复制代码
[root@localhost test]# ls                   ## 两个测试c程序
test01.c  test02.c
[root@localhost test]# cat test01.c         ## 后置递增运算符,表达式的值等于递增前的表达式的值
#include <stdio.h>
int main(void)
{
        int i;
        i = 10;
        printf("i++ = %d\n", i++);
        return 0;
}
[root@localhost test]# cat test02.c        ## 前置递增运算符, 表达式的值等于递增后的表达式的值
#include <stdio.h>
int main(void)
{
        int i;
        i = 10;
        printf("++i = %d\n", ++i);
        return 0;
}
[root@localhost test]# gcc test01.c -o aaa
[root@localhost test]# gcc test02.c -o bbb
[root@localhost test]# ls
aaa  bbb  test01.c  test02.c
[root@localhost test]# ./aaa
i++ = 10
[root@localhost test]# ./bbb
++i = 11
复制代码

 

 .

 

posted @   小鲨鱼2018  阅读(18)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-09-20 linux 中字符串处理函数 ${i%%.*}
2023-09-20 linux 中实现部分取反
2023-09-20 linux 中find命令同时对多个关键字进行查找
2023-09-20 linux 中 dirname和basename
2022-09-20 清华anaconda开源镜像下载站
2022-09-20 conda 中如何移除默认源
2022-09-20 conda中如何移除指定的源
点击右上角即可分享
微信分享提示