//===================================================== file = dtoclk.c ===== //= Program to convert a delta time stamp file into cumulative time = //=========================================================================== //= Notes: = //= 1) Input from input file "in.dat" to stdin (see example below) = //= * Comments are bounded by "&" characters at the beginning and = //= end of the comment block = //= 2) Output is to stdout = //=-------------------------------------------------------------------------= //= Example "in.dat" file: = //= = //= & --- Sample input file of delta time stamps --- & = //= 0.09 = //= 0.11 = //= 0.46 = //= 0.48 = //= 0.51 = //= 0.52 = //= 0.62 = //= 0.622 = //= 0.6222 = //= 0.80 = //= 0.801 = //=-------------------------------------------------------------------------= //= Example output (for above "in.dat"): = //= = //= & ------------------------------------------- dtoclk.c ----- & = //= 0.090000 = //= 0.200000 = //= 0.660000 = //= 1.140000 = //= 1.650000 = //= 2.170000 = //= 2.790000 = //= 3.412000 = //= 4.034200 = //= 4.834200 = //= 5.635200 = //= & ---------------------------------------------------------- & = //=-------------------------------------------------------------------------= //= Build: gcc dtoclk.c, bcc32 dtoclk.c, cl dtoclk.c = //=-------------------------------------------------------------------------= //= Execute: dtoclk < in.dat = //=-------------------------------------------------------------------------= //= Author: Kenneth J. Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (10/02/98) - Genesis = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() and feof() #include // Needed for atof() #include // Needed for strcmp() //=========================================================================== //= Main program = //=========================================================================== void main(void) { double delta_time; // Current time stamp value double clk_time; // Cumulative (clock) time char temp_string[256]; // Temporary string variable // Output banner printf("& ------------------------------------------- dtoclk.c ----- & \n"); // Loop for entire input file clk_time = 0.0; while(1) { // Input a value scanf("%s", temp_string); // This handles a comment bounded by "&" symbols if (strcmp(temp_string, "&") == 0) { do { scanf("%s", temp_string); } while (strcmp(temp_string, "&") != 0); scanf("%s", temp_string); } // Check if end-of-file if (feof(stdin)) break; // Set delta_time delta_time = atof(temp_string); // Compute cumulative (clock) time and output clk_time = clk_time + delta_time; printf("%f \n", clk_time); } // Output closing message printf("& ---------------------------------------------------------- & \n"); }