C语言的结构体

#include <stdio.h>

int main()
{

    /*定义一个结构体*/
    struct Student{
        int age;
        short name;
    };

    /*使用这个结构体定义一个新的变量*/
    struct  Student chengqiang;



    /* typedef:给数据类型起一个别名*/
    typedef int new_int;
    int one;
    new_int  one1;
    /*此时的  new_int = int  */


    /*给结构体使用 typedef  :非成员变量里面有递归:可以省略struct后面的Student1*/
    typedef struct  Student1{
        int age;
        short name;
    } Student1;
    /*使用这个结构体定义一个新的变量*/
    Student1 chengqiang1;


    /*定义给一个结构体链表*/
    typedef struct LNode{
        /*数据*/
        int data;
        /*下一个数据的指针地址*/
        struct  LNode *next;

    } LNode;
    LNode  head;
    LNode  *p;
    /*取 head的变量的指针给p   */
    p=&head;

    //操作变量中的值
    head.data=5;
    printf("1当前head中的data为:%d \n",head.data);
    /*操作指针指向地址上的值*/
    p->data=4;
    printf("2当前head中的data为:%d \n",head.data);

    return 0;
}

输出结果为:

1当前head中的data为:5 
2当前head中的data为:4 

进程已结束,退出代码为 0

posted @   成强  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2022-06-28 springboot validator参数校验器
2021-06-28 p标签自动换行
2021-06-28 bootstrap固定元素到底部
2021-06-28 bootstrap 点击回到顶部
2021-06-28 ckeditor使用crtl+v复制word文档中的图片
2021-06-28 django中在blog_list.html扩展一个html块元素,在blogs_with_type.html里面去继承
点击右上角即可分享
微信分享提示