zoukankan      html  css  js  c++  java
  • C提高_day03_const小专题

    const int a;     //代表整型变量a不能被修改

    int const b;

    const char *c;  //看const 是放在*的左边还是右边 看const是修饰指针变量,还是修饰所指向的内存空变量

    char * const d; char buf[100]

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    void main()
    {
        const int a=10;
        //a=11;
        int *p;
        {
            p=&a;
            *p=100;        //通过指针可以修改a的值
            printf("a:%d 
    ",a);
        }
    
            system("pause");
            return;
    }
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    void getmem1(char *p)
    {
        //p=1;
        //p=3;
        //
        p[1]='a';
        
        return;
    }
    
    void getmem2(char * const p)
    {
        p=1;
        p=3;
        //
        p[1]='a';
        
        return;
    }
    
    void main()
    {
        char *p1= NULL;
        const char *p2= NULL;
        p2=1;
        printf("helllo...
    ");
        system("pause");
        return;
    }
    Stay hungry,Stay foolish
  • 相关阅读:
    Django中的分页操作、form校验工具
    Django之form表单操作
    手写版本orm
    mysql注入问题
    MySQL基本操作
    初识数据库
    进程池、线程池
    信号量
    event事件
    死锁
  • 原文地址:https://www.cnblogs.com/zhesun/p/4959860.html
Copyright © 2011-2022 走看看