I think you need an array of pointesr to do the job:
You have only allocated memory to integers, which is really integers[0], therefore integers[1] & integers[2] have not had memory allocated.
================
EDIT: If
is declared, but
is used in the program, shouldn't the compiler give a warning?
===================
So you have to use malloc to allocate memory to all 3 pointers, right before the user inputs each number:
Code:
for ( i = 0; i < required; i++ )
{
printf("Please enter number #%d: ",i+1);
intergers[i] = malloc( sizeof(int) );
scanf("%d",&integers[i]);
}
and then you have to free the memory malloc has allocated to each pointer:
Code:
for(i=0;i<required;i++)
{
printf("Number #%d was %d\n",i+1,integers[i]);
getchar();
free(integers[i]);
}