文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>const

const

时间:2010-06-02  来源:checl1987_EE

#include<stdio.h>
/* const usage
 * const int *a= b;        //b is not variable, do not change b via a.
 * int * const a = b       //a is not variable, do not change a.
 * const int * const a = b //a and b are not variable
 */
int main(int argc, char *argv[])
{
    int str[4] = {1,2,3,4};
    int str_dif[4] = {5,6,7,8};
    const char *a = "abc";
    *a = 4; //error: assignment of read-only location

    int * const p = str;
    p = str_dif ;     // error: increment of read-only variable ‘p’
    const int * const q = str; //combine up 2

    return 0;
}
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载