Alright, i've got a problem! my program reads a text file that has x and y co-ordinates for a number of points on a graph, i can read the file ok, but need to find the max and min values for x and y thats where it goes wrong!
this is what i'e got:
Code:
void getPoints(void)
{
char buf[100];
int length =0;
int a;
int b;
int v=0;
int i =0;
FILE *stream;
if ((stream = fopen("Points.txt","r")) == NULL)
{
fprintf(stderr,"Error opening file.");
exit(1);
}
while(!feof(stream))
{
fgets(buf,30,stream);
if (sscanf(buf,"%d %d", &a,&b))
{
pointX[i] = a;
pointY[i] = b;
i++;
}
}
Max_X = pointX[0];
Min_X = pointX[0];
Min_Y = pointY[0];
Max_Y = pointY[0];
for(v=2;v=35266;v++)
{
if(Max_X < pointX[v] ) Max_X = pointX[v];
if(Min_X > pointX[v] ) Min_X = pointX[v];
if(Max_Y < pointY[v] ) Max_Y = pointY[v];
if(Min_Y > pointY[v] ) Min_Y = pointY[v];
}
}
i cann't get it to scan through all the coordinates correctly. any help appreciated!