博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如果函数传递的是结构体,小心在调用的参数中给指针重新赋值(拿tm结构体举例)
阅读量:4165 次
发布时间:2019-05-26

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

如果函数返回的是结构体,如下函数的tm_Compile_time

                            INT32 comptime;

                            CHAR compiletime[64];

                            struct tm comparetime;

                            ret=Getubootinfo(&comptime,&comparetime,compiletime);

INT32 Getubootinfo(INT32 *timet_Compile_time,struct tm *tm_Compile_time,CHAR *char_compiletime)

如果这样写,是错误的,指针进行了重新赋值,变了,跟外界的入参已经没有关系,最容易犯得错误

如图:

函数必须这样写才正确:这样指针并没有重新赋值,而是对内部的元素进行了赋值

你可能感兴趣的文章
python中thread的setDaemon、join的用法
查看>>
【MonogoDB】The high update operation of MongoDB
查看>>
MySQL集群简介与配置详解
查看>>
MySQL数据库集群进行正确配置步骤
查看>>
mongodb数据导入导出以及备份恢复
查看>>
mongodb数据导入导出以及备份恢复(二)
查看>>
mongodb数据导入导出以及备份恢复(三)
查看>>
mongodb数据导入导出以及备份恢复
查看>>
python整理二十七——egg文件制作与安装【仅提供链接地址】
查看>>
十一新疆之旅中邂逅的一首诗《黄河,母亲之河》
查看>>
【MongoDB】The description of index(一)
查看>>
MongoDB索引学习笔记
查看>>
【MonogDB】The description of index(二) Embedded and document Index
查看>>
【MonogDB】The description of index(三) Compose and unique Index
查看>>
【MongoDB】The basic operation of Index in MongoDB
查看>>
【MongoDB】The connection between two tables
查看>>
【MongoDB】windows下搭建Mongo主(Master)/从(slave)数据库同步
查看>>
【MongoDB】以前学习mongodb知识的补充
查看>>
【MongoDB】The description of procedure in MongoDB
查看>>
【MongoDB】mongoimport and mongoexport of data (一)
查看>>