void return type just means there is no return from that function.
C (especially older compilers), assume that any function with no prototype, will have an int return type.
Then when there is no return in the function, the compiler should give you an error message.
This is my take on your program:
Code:
#include <stdio.h>
#include <math.h>
//don't call this - just forces floating point formats to link in
//my old Borland Turbo C/C++
static void forcefloat(float *p)
{ float f = *p;
forcefloat(&f);
}
//The is is the function prototype - you should always use them.
//It's just the first line of the function, put before main();
void read_location(double *x, double *y);
struct coord{
double x;
double y;
};
struct coord array[20];
int main ()
{
int index=0, i;
putchar('\n');
do
{
read_location( &array[index].x, &array[index].y);
index++;
}while(index < 5);
for(i = 0; i < 5; i++)
printf("\n%d: x = %6lf, y = %6lf", i, array[i].x, array[i].y);
printf("\n\n\t\t\t Press Enter When Ready ");
while((i = getchar()) != '\n' );
i = getchar();
return 0;
}
void read_location(double *x, double *y)
{
printf("Enter x:\n");
scanf(" %lf", x);
printf("Enter y:\n");
scanf(" %lf", y);
}
Glad you got it working. Well done!