I have read about %02x format specifiers but when it comes to an argument of type char array, I am unable to understand the output of the following piece of code:
int main() {
// your code goes here
char str[6] = "abcde";
char t[3];
snprintf(t,3,"%02x",str);
printf("\t%s",t);
return 0;
}
Output:
bf
How str is being parsed under this format specifier, is a point of concern. What I feel, the output should have been "ab" (without quotes).
str
, in particular the lowest byte of said-address value would probably be rather telling.