- 8 points) In the standard C library,void *memmove(void *to, void *from, size_t n)
copies the block of n bytes pointed to by from to the block pointed to by to. The value to is If the blocks overlap, each byte in the block pointed to by from is accessed before a new value is written in that byte. Thus a correct copy is made, even when the blocks overlap.
(Notice that there is another function called memcpy() in the standard library which will produce undefined results when the blocks overlap. )
I provide you a skeleton program mymemmove.c.
What you are asked to do here is to replace the contents of the function mymemmove()(which cheats by simply calling the standard memmove()) in the attached program mymemmove.c with your implementation of the function.
You may use the supplied main() function to test your code, i.e. to check if your program produces exactly what are described in the comment lines in main().
- Obviously, you cannot call the standard memmove() function anywhere in your function mymemmove().
- You don’t need to worry about the array overflow problem in your function.
- (17 points) You implemented the push and pop operations on a stack in the previous assignment. Here, you are asked to do it again, but with 4 major changes as described below:
- The stack is going to be in the form of an array of double
- The third argument to push() and the second argument to pop() are going to be in the form of
e. a pointer to pointer which stores the address of the current top element on the stack.
Hint: in these functions, modify *top as the stack is updated.
- A global integer variable myerror is created for you. Its value could be STACK_FULL, STACK_EMPTY, and NORMAL. Use this variable in your push() and pop() functions to inform the main() function the status of the operations. Therefore, in main(), you are NOT allowed to use for loops with fixed number of iterations (i.e. fixed number of pushes/pops).
- Test your functions in main(). See details in the skeleton code c.
What to turn in?
Create a tarball file by the name of cs3335_a4_yourlastname.tar that includes
- The completed source code file c for question 1.
- The completed source code file c for question 2.
Submit the tarball file through BlazeVIEW by the due time.