#include #include #include #define COLPTR 1 // remove this line to use the array based max finder void printer(int * p, int l) { for (int i=0; imx) mx=*column; column++; } printf("MAX: %d\n", mx); } #else void colmax(int colLength, int column[]) { int mx = column[0]; for (int i=1; imx) mx=column[i]; } printf("MAX: %d\n", mx); } #endif //12:54 AM 73 F 65 F 76 % S 8 mph 0 mph 30.00 in 0.0 in int main(void) { FILE *f = fopen("/home/gtowell/Public246/Lab04/temps.txt", "r"); char aa[1000]; int temps[5][24] = { 0 }; char dep[5][24][20]; int *tp = (int *)temps; int row=0; int col=0; while (NULL != fgets(aa, 1000, f)) { char *tk = strtok(aa, "\t"); tk = strtok(NULL, "\t"); *(tp++) = (int)(strtof(tk, NULL)); tk = strtok(NULL, "\t"); for(int i=0; i<20 && tk!='\0'; i++) { dep[row][col][i]=*(tk++); } //strcpy(dep[row][col], tk); // the for loop is equivalent to this strcpy col++; if (col>=24) { col=0; row++; } } fclose(f); printer((int *)temps, (5*24)); for (int i=0; i<5; i++) { #if COLPTR colmaxP(24, temps[i]); #else colmax(24, temps[i]); #endif } dewPrinter(5,24,20,dep); }