[cs23021] lab 10

Mikhail Nesterenko mikhail at cs.kent.edu
Mon Nov 1 13:16:27 EDT 2010



This is an example of how not to code Lab 10. Instead, you need to
dynamically allocate the array using "new" operation. This operation
returns the pointer to the array which you would then need to
manipulate.

thanks,
--
Mikhail


> I am a little confused about Lab10_DynamicInt. What do you want us to do
> with the pointer?
> 
> This is what I have so far, but I am not doing anything with the pointer.
> 
> //////////////////////////////////////////////////////////////////////////////
> // includes and using directive
> 
> 
> // function prototypes //
> int getInput(); //take input from user and return as integer
> void populateArr(int [], int); // take input from the user for every integer
> in the array
> void printArray(int[], int); // print every integer in the array
> void printInt(int); // print an integer
> 
>  int main()
> {
>   int *dynArray;  // What should I do with the pointer? It seems to be not
> needed
>   int size;       // array size
>   cout << "Enter number of integers: ";
>   size=getInput();
>   int dynamicArray[size];
>   populateArr(dynamicArray, size);
>   printArray(dynamicArray, size);
> }
> 


More information about the cs23021-2 mailing list