/* This should be used in conjunction with routines.c that i gave out earlier. Be sure to revise the definition of DATAFILE according to your situation. */ #include #include #include "coords.h" #define DATAFILE "continents.dat" #define LEFT -17.00 /* value of u at left of window */ #define RIGHT 23.00 #define BOTTOM 32.00 /* value of v at bottom of window */ #define TOP 72.00 main() { double latitude, longitude, altitude; FILE *fp_in, *fopen(); int printing, N, Q; point p, q; fp_in = fopen(DATAFILE,"r"); if (fp_in==NULL) error_4(); fprintf(stderr,"\nWhat latitude should we use? "); scanf("%lf", &latitude); fprintf(stderr,"\n\nWhat longitude should we use? "); scanf("%lf", &longitude); fprintf(stderr,"\n\nAnd what altitude should we use? "); scanf("%lf", &altitude); position_login_signature(); begin_small_text(); printf("Login name: %s",getlogin()); end_small_text(); set_pen(3); printf("w %f %f %f %f\n", LEFT, BOTTOM, RIGHT, TOP); while (1) { q = p; Q = fscanf(fp_in,"%d",&printing); if (Q <= 0) {error_1(); break;} Q = fscanf(fp_in,"%lf",&p.y_coord); if (Q <= 0) {error_2(); break;} Q = fscanf(fp_in,"%lf",&p.x_coord); if (Q <= 0) {error_3(); break;} if (printing==1) display(p,q,latitude,longitude,altitude); } label_picture(latitude, longitude, altitude); fclose(fp_in); } display(p,q,latitude,longitude,altitude) double latitude, longitude, altitude; point p, q; { segment(p,q); } label_picture(latitude, longitude, altitude) double latitude, longitude, altitude; { } error_1() { fprintf(stderr,"\nError in reading printing.\n"); } error_2() { fprintf(stderr,"\nError in reading y_coord.\n"); } error_3() { fprintf(stderr,"\nError in reading x_coord.\n"); } error_4() { fprintf(stderr,"\nDATAFILE does not exist.\n"); }