onst和volatile分析

一、const和volatile分析

  1、const修饰变量

  # 在c语言中const修饰的变量时只读的,其本质还是变量

  # const修饰的变量会在内存占用空间

  # 本质上const只对编译器有用,在运行时无用

  原来const不是真的常量

onst和volatile分析

# 在C语言中const修饰的数组是只读的

  #const修饰的数组空间不可以被改变

  const int A[5] = {1, 2, 3, 4, 5}

  int *p = (int *)A;

  int i = 0;

  for(i=0; i<5; i++)

  {

  p[i] = 5-i;//报错

  }

  3、const修饰指针

  # const int *p; //p可变,p指向的内容不可变

  # int const *p; //p可变,p指向的内容不可变

  # int *const p; //p不可变,p指向的内容可变

  # const int *const p; //p不可变, p指向的内容不可变

http://v.17173.com/playlist_16648348?retcode=0
http://v.17173.com/playlist_16652883?retcode=0
http://v.17173.com/playlist_16654641?retcode=0
http://v.17173.com/playlist_16657769?retcode=0
http://v.17173.com/playlist_16659068?retcode=0
http://v.17173.com/playlist_16659895?retcode=0
http://v.17173.com/playlist_16661064?retcode=0
http://v.17173.com/playlist_16662125?retcode=0
http://v.17173.com/playlist_16663174?retcode=0
http://v.17173.com/playlist_16664810?retcode=0
http://v.17173.com/playlist_16665458?retcode=0
http://v.17173.com/playlist_16666559?retcode=0
http://v.17173.com/playlist_16668088?retcode=0
http://v.17173.com/playlist_16669573?retcode=0
http://v.17173.com/playlist_16747281?retcode=0
http://v.17173.com/playlist_16748181?retcode=0
http://v.17173.com/playlist_16748993?retcode=0
http://v.17173.com/playlist_16749763?retcode=0
http://v.17173.com/playlist_16750655?retcode=0
http://v.17173.com/playlist_16757239?retcode=0
http://v.17173.com/playlist_16757776?retcode=0
http://v.17173.com/playlist_16758843?retcode=0
http://v.17173.com/playlist_16759417?retcode=0
http://v.17173.com/playlist_16760157?retcode=0
http://v.17173.com/playlist_16760903?retcode=0
http://v.17173.com/playlist_16761521?retcode=0
http://v.17173.com/playlist_16763013?retcode=0
http://v.17173.com/playlist_16763743?retcode=0
http://v.17173.com/playlist_16764530?retcode=0
http://v.17173.com/playlist_16765270?retcode=0
http://v.17173.com/playlist_16765842?retcode=0
http://v.17173.com/playlist_16766530?retcode=0
http://v.17173.com/playlist_16767315?retcode=0
http://v.17173.com/playlist_16768553?retcode=0
http://v.17173.com/playlist_16768997?retcode=0
http://v.17173.com/playlist_16769523?retcode=0
http://v.17173.com/playlist_16770218?retcode=0
http://v.17173.com/playlist_16770814?retcode=0
http://v.17173.com/playlist_16771317?retcode=0
http://v.17173.com/playlist_16772091?retcode=0
http://v.17173.com/playlist_16772758?retcode=0
http://v.17173.com/playlist_16773477?retcode=0
http://v.17173.com/playlist_16773960?retcode=0
http://v.17173.com/playlist_16774386?retcode=0
http://v.17173.com/playlist_16774960?retcode=0
http://v.17173.com/playlist_16775600?retcode=0
http://v.17173.com/playlist_16776142?retcode=0
http://v.17173.com/playlist_16776614?retcode=0
http://v.17173.com/playlist_16777034?retcode=0
http://v.17173.com/playlist_16777585?retcode=0


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值