zoukankan      html  css  js  c++  java
  • C 语言基本知识

    C 语言基本知识

    1. 堆和栈,以及常用内存块

    (1) 栈(stack): 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈;

    (2) 堆(heap): 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表。

    2. 结构体(struct)

    #include<stdio.h>
    
    // Only define of struct
    struct struct1{
        char name[20];
        float height;
        char job[20];
    };
    struct struct1 student1 = {"s1",180,"IT"};
    
    // Define first and instantiation
    struct stuct2{
        float name[20];
        float height;
        char job[20];
    }student2;
    student2.name[0] = 's';
    student2.height = 190;
    student2.job[0] = 't'; 
    
    // typedef
    typedef struct _struc{
        char name[20];
        float height;
        char job[20];
    }stuc_test;
    stuc_test student3 = {"s3",200,"IT"}; // stuc_test equals to struct _struc
    
    int main()
    {
        printf ("student1 info: 
    ");
        return 0;
    }   
    
  • 相关阅读:
    git 常用命令
    目录
    算法--双栈排序
    算法--栈的翻转练习题
    算法--双栈队列
    算法--可查询最值的栈练习题
    Spark算子--union、intersection、subtract
    Spark算子--take、top、takeOrdered
    Spark算子--countByKey
    Spark算子--SortBy
  • 原文地址:https://www.cnblogs.com/zk47/p/5758929.html
Copyright © 2011-2022 走看看