$30.00
Description
Questions
1.(40points)Writeafunctionintcrypticcalculator(void*payload)
Where:
• If the first byte in payload is a character ’*’ representing the multiplication operation, you are to return the product of 3 short ints starting at bytes 3, 5 and 7.
• If the first byte in the payload is a character ’/’ representing division, you are to return the quotient when you divide int starting at byte 5 by short int starting at byte 3. If short int starting at byte 3 is 0, you are to return
0xBAD.
• If the first byte is neither ’*’ or ’/’, you are to return 0xBAD.
HINT: Cast payload to an appropriate appropriate structure. Byte 1 is at &payload, byte 3 is at &payload + 2, byte 5 is at &payload + 4 and so on.
2.(40points)Writeafunction:voidmymemcpy(void *dst, void *src, unsigned int num bytes) that copies num bytes from memory pointed
tobysrctomemorypointedtobydst.HINT:Loopnumbytestimesandcopy onecharatatimefromsrctodst.
3.(20 points)Writeafunction:void swapstrs(char*s1, char *s2) that swaps two character strings at s1 and s2. Assume both strings s1 and s2 to be of same length.