I have uint8_t orig[ETH_ALEN];
How can I print it using __printf(3, 4)
which is defined as #define __printf(a, b) __attribute__((format(printf, a, b)))
the Orig should be ethernet hardware address.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to construct a format string that’s suitable. The
printf()function has no way of printing an array in one go, so you need to split it and print eachuint8_t:The
& 0xffis to ensure only 8 bits are sent toprintf(); they shouldn’t be needed for an unsigned type likeuint8_tthough so you can try without too.This assumes a regular 48-bit MAC, and prints using the conventional colon-separated hex style.