I'm trying to determine array length of msg
on the below code. I used strlen
and sizeof
but they don't return 6. What function can I use to determine the length of uint8_t
array or how can I modify the below code (osal_DataLenght()
func)?
int osal_DataLength( char *pString ){
return (int)( strlen( pString ) );
}
void setNewLevel( uint8_t newLevel ){ //GW specific
uint8_t msg[8] = {'\0'};
msg[0] = '0';
msg[1] = '7';
msg[6]= newLevel;
//msg[7] = '0';
printf("the array length:%d\n", osal_DataLength(msg) );
}
int main(void){
setNewLevel(0xD5);
return 0;
}
msg
is 8, whether you initialize all the elements or not. – Godinez