CSC145/290 Assignment 1 : C Due Thursday 9/13/2001 1. Write a function that takes an integer (assume 32 bit integers) as argument and return its most signifcant (first) byte as a char. This is similar to the big-little endian program I showed in class. It should be easy if you really understood what I was doing. If you can, run this program on both a sparc and an intel machine. Are the results different? 2. Write a C program that takes an array of integers and its size as arguments and return a NEW array that contains the contents of the original array in reverse order. For this assignment you need to research or review the connection between arrays and pointers in C. Be sure that you use dynamic arrays, since once the function exits, its scope is destroyed. And if you make the array with malloc or calloc you must *free* it when it's nolonger needed. int * reverse(int A[], int size) 3. Review/research bitwise operators in C (|, &, etc). In particular, find out how to take the bitwise exclusive-or of two values. (A XOR B if and only if one of A,B is 1 and the other one is 0). I'm just using "XOR" as pseudo code - you'll have to find the actual symbol. Here's a simple encription scheme: A XOR B XOR B = A. That is, if we want to encript A we XOR it with a "key" B. And to decript it, we XOR it again with B to get the original A back. You cannot decript a message without knowing whic.ch key it was originally encripted in. Revise the simple file-copying program I showed in class so that you can encript/decript a file. Call your program "fcrypt". For example, if I type: fcrpty file1 key1 file2 Then file2 should contain the result of bitwise XOR'ing the contents of file1 with key1. If key1 is shorter than file1, simply repeat the key1 sequence until it's large enough (you can use the *lseek* function go back to the beginning of a file - do "man lseek" for details). That is, if file1 is the sequence 11011, and key1 is 01, then just extend key1 by repeating it until it's big enough: 01010.