The first line of a file contains a positvie integer value, n. the file then contains n additional lines.
each line contains a pair of integers that represent the x and y coordinates of a point
the name of the file comes in as argv[1]
first read in the number n, then malloc up some space to form an array of n structs. each struct will contain 2 fields. a struct represents a point
then fill the array of structs with the n points- start filling at index 0 and go left to right
Sweep through the array and loate the index of the array where the lowermost then leftmost point is located. Refer to this as index j.
print out both the index of the array where the lowermost then leftmost point is located and print the x and y coordinates.
I'm not quite sure how to get this going.
All I have so far so any help is appreciated, thanks.
Code
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] ) {
struct point{ int x; int y; }point;
FILE *fin;
int n, i, lowest;
fin = fopen( argv[1], "r" );
fscanf( fin, "%d", &n );
point = malloc( sizeof( point ) ); // malloc up space to form an array of structs
for( i = 0; i < n; i++ ) {
fscanf( fin, "%d%d", point.x, point.y );
if( point[0].y < point[1].y ) point[0].y = lowest;