zoukankan      html  css  js  c++  java
  • 66 回顾总结

    定义 说明
    int l_v1 定义整型变量
    int *lp 定义一个指针
    int l_arr[10] 定义一个数组
    int *lp[10] 定义一个指针数组
    int f_test() 定义一个函数,返回值int
    int * f_test() 定义一个函数,返回值是int 指针
    int **lp 定义一个二级指针



    上述表,除了倒数第二个,没有讲过,其他都讲过了.大家应该做到一目了然,熟悉掌握其在内存中的本质是什么.
    常量指针和指针常量

    const(代表常量)    *(指针)
    int const  *l_v1; //常量指针,指针的地址可以修改,内容不能重复赋值.
    int * const l_v1;//指向的内存地址不可以修改,但是内容可以改变. 必须初始化.

    const char  *  l_arr = char const * l_arr


    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>

    int f_strlen(const char * p_1) {
     int l_lenth = 0;
     while (p_1[l_lenth] != '') {
      l_lenth++;
     }
     return l_lenth;
    }

    int f_strcpy(char * p_dest, char const * p_src) {
     int l_length = 0;
     while (p_src[l_length] != '') {
      p_dest[l_length] = p_src[l_length];
      l_length++;
     }
     return l_length;
    }

    void main() {
     char l_v1[10] = "123456789";
     char l_v2[10] = { 0 };
     f_strcpy(l_v2, l_v1);
     system("pause");
    }


    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>

    void f_printfint(int * p_1, int l_length) {
     for (size_t i = 0; i < l_length; i++) {
      printf("%d ", p_1[i]);
     }
    }

    void main() {
     int l_array[] = { 123,456 };
     f_printfint(l_array, sizeof(l_array) / sizeof(int));
     system("pause");
    }

    //在写一个关于参数是int类型数组的函数时,最好再提供一个参数,表示这个数组的内存长度,方便读写遍历控制.
    //如果函数的参数是字符串,就不需要这个字符串就多长这个参数,比如strcpy

  • 相关阅读:
    Vue源码解读-构造函数
    在vue中使用async/await遇到的坑
    vue单页(spa)前端git工程拆分实践
    携带参数隐藏必要参数,瞬间改变浏览器地址
    解析Nuxt.js Vue服务端渲染摸索
    WebSocket的使用(基于VUE与SpringBoot)
    设计模式之桥接(bridge)模式
    设计模式之观察者模式
    设计模式之代理模式、适配器模式和外观模式
    设计模式之工厂模式
  • 原文地址:https://www.cnblogs.com/xiaodaxiaonao/p/7995013.html
Copyright © 2011-2022 走看看