Pointers, Dynamic Memory Allocation

  1. Dynamic Integer Array. Study Tasks feature of Eclipse described here. As you work on the below project, demonstrate to the instructor setting and deleting a task.

    Create a project titled Lab10_DynamicInt. Write a program that dynamically stores and then prints the array of user-input integers. Your program should ask the user for the number of integers to be entered. Then the program should allocate the appropriate-size array dynamically, store the integers and then print them out. You should use this template for your program. Here is an example dialog of your program:

    Enter number of integers: 5
    Enter integers: -3 -4 6 7 23
    You entered: -3 -4 6 7 23
    

  2. Variable Size Array. Create a project titled Lab10_VarArray. Write a program that allows the user to add or remove an integer number to a collection of integers and then prints all of them them in the increasing order. You can assume that the user never enters the same number more than once.

    Here is an example dialog:

    done? [y/n] n
    add or remove? [a/r] a
    input number: 5
    done? [y/n] n
    add or remove? [a/r] a
    input number: 8
    done? [y/n] n
    add or remove? [a/r] r
    input number: 8
    done? [y/n] n
    add or remove? [a/r] a
    input number: 3
    done? [y/n] n
    add or remove? [a/r] a
    input number: 12
    done? [y/n] y
    your numbers: 3 5 12
    

    The size of the user input can be arbitrarily large. For this program you need to implement an integer array whose size varies as necessary to accommodate the user input. You should use the functions prototyped in this header file. The functions there are as follows:

    You are free to modify the header file and as you see fit. For example, you may consider defining a function that copies portions of the array.

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.