博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
结构体测试用例struct(指针用例)结构体里面含有指向自己的指针怎么用
阅读量:4166 次
发布时间:2019-05-26

本文共 527 字,大约阅读时间需要 1 分钟。

struct node {

    int data;
    struct node *next;
    };

VOID teststurct()

{

    DBG_PRINT("测试用例teststurct******************\n");

    
    struct node *head, first;
    struct node *second = (struct node *)malloc(sizeof(struct node));
    head = &first;
        first.data = 1;
        first.next = second;
        int a=1,i;
    for(i=0;i<10;i++)
    {
      second->data = a++;
      second->next=(second+sizeof(struct node));
      second+=sizeof(struct node);
     // first=first.next
    }
    second-=sizeof(struct node);
    second->next = NULL;
    while (head) {
    printf("%d\n", head->data);
    head = head->next;
    }

    

}

测试结果如下:

你可能感兴趣的文章
XHProf-php轻量级的性能分析工具
查看>>
就在昨天,全球 42 亿 IPv4 地址宣告耗尽!
查看>>
Jackson Tree Model Example
查看>>
常用js收集
查看>>
如何防止sql注入
查看>>
springmvc传值
查看>>
在Eclipse中查看Android源码
查看>>
[转]C语言printf
查看>>
对话周鸿袆:从程序员创业谈起
查看>>
Mysql中下划线问题
查看>>
Xcode 11 报错,提示libstdc++.6 缺失,解决方案
查看>>
vue项目打包后无法运行报错空白页面
查看>>
1136 . 欧拉函数
查看>>
面试题:强制类型转换
查看>>
Decorator模式
查看>>
Template模式
查看>>
Observer模式
查看>>
高性能服务器设计
查看>>
图文介绍openLDAP在windows上的安装配置
查看>>
Pentaho BI开源报表系统
查看>>