嗨,Sizeof不使用类型,只使用变量。我希望下面的代码工作,但它不起作用。为了工作,我必须做以下的调整(我觉得很可怕):谁能给我一个提示,或者告诉我如何做类型的工作。谢谢。
以上来自于百度翻译
以下为原文
Hi,
Sizeof does not work with types, only with variables.
I expected the code below to work, but it does not work.
#define NAME_TASK_SIZE (16)
typedef struct {
unsigned char name[NAME_TASK_SIZE];
float descida;
float descanso;
float subida;
}t_tupla;
void DATABASE_Delete(unsigned char index)
{
unsigned char i;
for(i=0;i<(sizeof t_tupla);i++)
EEPROM_Write_Byte(((sizeof t_tupla)*index)+3+i,0xFF);
}
To work I had to make the following adaptation (which I found horrible):
void DATABASE_Delete(unsigned char index)
{
unsigned char i;
t_tupla var;
for(i=0;i<(sizeof var);i++)
EEPROM_Write_Byte(((sizeof var)*index)+3+i,0xFF);
}
Can anyone give me a hint or tell how to do sizeof work with types.
Thank you.