• 对内存分配的理解 自动变量 局部变量 临时变量 外部变量 字符串长度 C语言可以看成由一些列的外部对象构成


    Status ListInsert_Sq(SqList *L,int i,LElemType_Sq e) {

    LElemType_Sq *newbase;

    LElemType_Sq *p,*q;

    if(i<0 || i>(*L).length+1)

    return ERROR; // i值不合法

    if((*L).length >= (*L).listsize) { //若存储空间已满,需开辟新空间

    newbase = (LElemType_Sq*)realloc((*L).elem,((*L).listsize+LIST_INCREMENT)*sizeof(LElemType_Sq));

    if(!newbase)

    exit(OVERFLOW);

    (*L).elem=newbase;

    (*L).listsize+=LIST_INCREMENT;

    }

    q=&(*L).elem[i]; // q为插入位置

    for(p=&(*L).elem[(*L).length-1]; p>=q; --p)

    *(p+1)=*p; // 插入位置及之后的元素右移

    *q=e; // 插入e

    ++(*L).length; // 表长增1

    return OK;

    }

    void SequenceList() {

    SqList L;

    int i;

    LElemType_Sq e;

    InitList_Sq(&L);

    printf(" SequenceList ");

    //ListInsert_Sq(&L,0,0);

    ListInsert_Sq(&L,1,1);

    ListInsert_Sq(&L,2,4);

    ListInsert_Sq(&L,3,666);

    ListTraverse_Sq(L,SequenceList_PrintElem);

    i=ListLength_Sq(L);

    printf(",ListLength_Sq=%d",i);

    }

    Status ListTraverse_Sq(SqList L,void(Visit)(LElemType_Sq)) {

    int i;

    for(i=-2; i<=L.length; i++) {

    Visit(L.elem[i]);

    printf("--&(L.elem[%d])=%d--",i,&(L.elem[i]));

    }

    }

    SequenceList

    e=1650049076,&e=2293104--&(L.elem[-2])=4518744--

    e=268582613,&e=2293104--&(L.elem[-1])=4518748--

    e=3827376,&e=2293104--&(L.elem[0])=4518752--

    e=1,&e=2293104--&(L.elem[1])=4518756--

    e=4,&e=2293104--&(L.elem[2])=4518760--

    e=666,&e=2293104--&(L.elem[3])=4518764--,ListLength_Sq=3

    --------------------------------

    Process exited after 0.01549 seconds with return value 0

    请按任意键继续. . .

    https://github.com/toywei/Data-Structure

    字符串常量就是字符数组,字符串的内部标识使用一个空字符''作为串的结尾
    存储字符串的物理存储单元数比括在双引号中的字符数多1个
    C语言对字符串的长度没有限制,但是程序必须在扫描完整整个字符串后才能确定字符串的长度

    C has been designed to make functions efficient and easy to use; C programs generally consist of many small functions rather than a few big ones. A program may reside in one or more source files. Source files may be compiled separately and loaded together, along with previously compiled functions from libraries. We will not go into that process here, however, since the details vary from system to system.

    C语言程序一般都由许多小的函数组成,而不是由少量较大的函数组成。一个程序可以保存在一个或多个源文件中。各个文件可以单独编译,并可以与库中已编译

    过的函数一起加载。

    The standard clarifies the rules on the scope of names; in particular, it requires that there be only one definition of each external object. Initialization is more general: automatic arrays and structures may now be initialized.

    C语言可以看成由一些列的外部对象构成,这些外部对象可能是变量或函数。形容词external与internal相对的,internal用于描述定义在函数内部的函数参数及变量。

    外部变量定义在函数之外,一次可以再许多函数中使用。

    由于C语言不允许在一个函数中定义另外其他函数,因此函数本身是“外部”的。

    默认情况下,外部变量与函数具有下列性质:通过同一个名字对象(标准中把这一性质称为外部链接)。

    princf("hello, world "};

    printf接受的是一个指向字符数组第一个字符的指针。

    程序可以通过检查空字符找到字符数组的结尾。

    字符串常量可以通过指向其第一个元素的指针访问。

  • 相关阅读:
    套接字socket
    Windows环境下教你用Eclipse ADT 插件生成.h/.so文件,Java下调用JNI,轻松学习JNI
    How to start/stop DB instance of Oracle under Linux
    Oracle SGA具体解释
    Oracle Study之--Oracle 单实例11.2.0.1.0升级到11.2.0.3.0
    MapReduce(十六): 写数据到HDFS的源代码分析
    Spring表达式语言SpEL简单介绍
    LinkCutTree详解
    洛谷P3379 【模板】最近公共祖先(LCA)(树链剖分)
    树链剖分详解
  • 原文地址:https://www.cnblogs.com/rsapaper/p/10418617.html
Copyright © 2020-2023  润新知