/**************************** * Project 1 * Output Test File 1 * Good Student * CS 3113 * Dr. Hougan ****************************/ //Include Files #include #include #include #include #include "out_test.h" /****************************/ //Main function //Takes in a file name, then //writes it to the stdout 1000 //times, keeping track of the time //it takes each time int main(int argc, char* argv[]) { //variable declarations char* inputfilename; char inputStore[100000]; FILE *input; struct stat fileStats; int i = 0; //if command line does not contain filename, exit if (argc < 2) { printf("Too few arguments given.\nCorrect syntax: %s \n", argv[0]); exit(0); } //read in the file given in the command line inputfilename = argv[1]; if ((input = fopen(inputfilename, "r")) == NULL) { printf("Either the file %s does not exist, or there has been a problem opening it. Please try again."); } else { //get file statistics stat(inputfilename, &fileStats); //if the file is under a certain size, continue if (fileStats.st_size < 100000) { //outputs file size fprintf(stderr, "File Size: %d\n", fileStats.st_size); //counts how big the file is while ((inputStore[i] = fgetc(input)) != EOF) { i++; } //runs the test fprintf(stderr, "Overall Time Delta: %.1f ticks", fileToStdOut(inputStore, 1000, i)); } else { printf("File too large for this program, please use something under 100k."); } } return 0; }