C job interview - casting and comparing
问题 I was confronted with a tricky (IMO) question. I needed to compare two MAC addresses, in the most efficient manner. The only thought that crossed my mind in that moment was the trivial solution - a for loop, and comparing locations, and so I did, but the interviewer was aiming to casting. The MAC definition: typedef struct macA { char data[6]; } MAC; And the function is (the one I was asked to implement): int isEqual(MAC* addr1, MAC* addr2) { int i; for(i = 0; i<6; i++) { if(addr1->data[i] !=