ios - NSString stringWithFormat added "ffffff" -


i'm trying bytes nsdata , put in nsstring. while doing "ffffff" added simultaneously :

char *array = (char *)[deviceinfo bytes]; return [nsstring stringwithformat:@"%02x:%02x:%02x:%02x:%02x:%02x", array[5],array[4],array[3],array[2],array[1],array[0]]; 

returns "53:ffffffcb:ffffffb8:51:09:fffffff0"

the issue relates sign extension compiler promotes signed char unsigned int. numbers fffff negative. %x format expects unsigned int argument.

declaring array correctly fix issue:

const uint8_t *array = [deviceinfo bytes]; 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -