Here is the general assignment: "Write a C program that calculates the average price of a company’s stock over a specified period of time. Your program should ask the user the number of prices that will be entered and then dynamically allocate the correct amount of memory to store the prices. Pass this allocated memory into functions that calculate the average price."
Here's what I have so far
I'm having problems just allocating the memory, what am I doing wrong with the malloc?? Then later I know I will probably need a function with an array to where the stock prices are stored and then calculated.Code:/*
My name is Jack Trocinski
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
double i; // number of stocks
double *ptr; // memory allocation
printf("Please enter the amount of stocks prices you wish to have calculated: ");
scanf("%d", &i);
*ptr = malloc( i * sizeof(*ptr) );
system("pause");
return 0;
}