c结构体的有关问题
c结构体的问题
struct MYTIME //时间结构体
{
unsigned int wYear;
unsigned int wMonth;
unsigned int wDayOfWeek;
unsigned int wDay;
unsigned int wHour;
unsigned int wMinute;
unsigned int wSecond;
unsigned int wMilliseconds;
};
struct MESSAGE_INFO //信息结构体
{
struct MYTIME ReceiveTime; //接收时间
char *Latitude; //纬度
char *Longitude;//经度
char *Speeds; //速度
char *Direction; //方向
};
struct MYTIME old_time;
struct MESSAGE_INFO message_info;
我已经给old_time中的各个成员,怎么把old_time中的值赋给message_info中的ReceiveTime成员
------解决方案--------------------
message_info.ReceiveTime = old_time;
------解决方案--------------------
整个结构体用 = 号赋值过去即可 。。。
如果是其中某几个成员赋值,
那么使用成员赋值:
message_info.ReceiveTime.wYear = old_time.wYear; //wYear 赋值
... //同上 ...
------解决方案--------------------
一楼和二楼同为正解
------解决方案--------------------
二楼说的正确
不过我想知道lz是想问什么呢?搞不明白
struct MYTIME //时间结构体
{
unsigned int wYear;
unsigned int wMonth;
unsigned int wDayOfWeek;
unsigned int wDay;
unsigned int wHour;
unsigned int wMinute;
unsigned int wSecond;
unsigned int wMilliseconds;
};
struct MESSAGE_INFO //信息结构体
{
struct MYTIME ReceiveTime; //接收时间
char *Latitude; //纬度
char *Longitude;//经度
char *Speeds; //速度
char *Direction; //方向
};
struct MYTIME old_time;
struct MESSAGE_INFO message_info;
我已经给old_time中的各个成员,怎么把old_time中的值赋给message_info中的ReceiveTime成员
------解决方案--------------------
message_info.ReceiveTime = old_time;
------解决方案--------------------
整个结构体用 = 号赋值过去即可 。。。
如果是其中某几个成员赋值,
那么使用成员赋值:
message_info.ReceiveTime.wYear = old_time.wYear; //wYear 赋值
... //同上 ...
------解决方案--------------------
一楼和二楼同为正解
------解决方案--------------------
二楼说的正确
不过我想知道lz是想问什么呢?搞不明白