The following programme is supposed to use pointers totype double variables to accept 10 numbers, sort them, print them.
Sorry if it's not formatted well, I'm using a text-based brwserCode:/* D14Ex7.c - programme to use pointers to type double to accept 10 numbers *
* from the user, sort them and print them to the screen. */
#include <stdio.h>
double *ptr[10];
int main ( void )
{
int cnt;
printf("\t\t\t====You must enter 10 numbers====\n");
for (cnt = 0; cnt < 10; cnt++)
{
printf("\nEnter number %d: ", cnt);
scanf("%lf", ptr[cnt]);
}
for (cnt = 0; cnt < 10; cnt++)
{
printf("\n%f", *ptr[cnt]);
}
return 0;
}
I'll check later to see if I need to repost the code. The poblem is that after entering a first number, the programme generates a `segmentation fault' error and goes to the shell.
Any suggestions?