I'm trying to fix someones code for them but I've got myself stuck.
Code:
int main()
{
float x = 0, temp=0 , high, low;
int num,i,*ptr,sum = 0,mean;
char choose;
printf("This program will ask the user for a list of numbers.\n");
printf("Then calculate the median or mean average.\n\n");
printf("How many numbers are you going to put in?\n: ");
scanf("%d",&num);
ptr = (int*) malloc ( num * sizeof (int)); //Creates enough room for the array
if (ptr == NULL) printf("Malloc failed");
for (i=0;i<=num;i++) { //Fills the array with inputted values
printf("i = %d\n",i);
scanf("%d",*(ptr + i)); //PROBLEM HERE
}
After I've inputted 3 values ( I should be able to put much more in ) in crashes my dos prompt. Can anyone here see whats wrong?
This isn't full code by the way, if you are wondering why there are lots of unused variables.