[mw_shl_code=c,true]想获取系统时间 并赋值给变量char *b,但数据结构不同[/mw_shl_code]
[mw_shl_code=c,true]typedef struct
{
uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour.
This parameter must be set to a value in the 0-12 range
if the RTC_HourFormat_12 is selected or 0-23 range if
the RTC_HourFormat_24 is selected. */
uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time.
This parameter can be a value of @ref RTC_AM_PM_Definitions */
}RTC_TimeTypeDef; [/mw_shl_code]
[mw_shl_code=c,true]char *b="166";//txt文件名[/mw_shl_code]
想把RTC_Minutes赋值给*b;
[mw_shl_code=c,true]*b=&RTC_TimeStruct.RTC_Minutes;[/mw_shl_code]
[mw_shl_code=c,true]但这样不行[/mw_shl_code]
附:RTC代码如下
[mw_shl_code=c,true]RTC_GetTime(RTC_Format_BIN,&RTC_TimeStruct);
sprintf((char*)tbuf,"Time:%02d:%02d:%02d",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
LCD_ShowString(30,140,210,16,16,tbuf);[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
请参考:http://blog.csdn.net/mhjcumt/article/details/7351032
---------------------------------
谢谢,以解决
在C语言中没有一种内建(built-in)的方法去表示指针常量,所以当我们使用它的时候通常先写成整型常量的形式,然后再通过强制类型转换把它转换成相应的类型,如:int * , double * , char *等。 所以后面所示的做法是不行的: int *p = 0x12345678 ; 正确的方式应为:int *p = (int *) 0x12345678
一周热门 更多>