1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
//Main.c with extra stuff removed to save space
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
//function prototypes and global constants
#include "StcWx2_Version2.Header.h"
#define DATAFILE_COUNT 4
#define DATASOURCE_OPTIONS_COUNT 7
#define SEARCH_OPTIONS_COUNT 7
#define HEADER_MAX_WIDTH 55
int main(void)
{
clock_t start,end;
start = clock();
unsigned short int
*year, *month, *day;
short int
*high, *low;
int
i=0, k=0, records = 0, datasource, search_type,
search_match_index[1000], datasources_used, dummy;
char
f[FILENAME_MAX],
selected_filename[FILENAME_MAX],
datasource_options[DATASOURCE_OPTIONS_COUNT][FILENAME_MAX] = {
"StcWx00to29.txt", "StcWx30to59.txt", "StcWx60to90.txt",
"StcWx91to08.txt", "TestDataSet.txt", "All files",
"Enter a file name" },
search_options[SEARCH_OPTIONS_COUNT][256] = {
"Record highs and lows",
"Number of days in a selected year with no precipitation",
"Longest dry period",
"Most snowy days in a season",
"Record highs and lows on your birthdays",
"Record highs and lows since your birthday",
"Quit Program" };
float
*precip;
double running_time;
//Some pointers
FILE* fptr[DATAFILE_COUNT];
//switch statements for search options,
//wrapped in do while for error checking
do{
//user prompts
search_type = ChooseSearchType( search_options, SEARCH_OPTIONS_COUNT );
switch( search_type ){
case 0:
.....
case 6:
exit(0);
//no default search_type only returns 0-6
}
}while( search_type == -1 );
//.....more code, then ends with...
//some timing calculations
end = clock();
running_time = (double)(end - start) / (double)CLOCKS_PER_SEC;
printf ("\n\nExecution time: %.4lf seconds\n", running_time );
system( "PAUSE" );
return 0;
}
|