//============================================ file = interval2vector.c ===== //= Program to convert BUSY and IDLE intervals to vectors = //=========================================================================== //= Notes: = //= 1) Input from input file "in.dat" to stdin (see example below) = //= 2) Output is to stdout = //= 3) Input is a series of tuplets X,N where X is "I" (for idle) or "B" = //= (for busy) and N is number of minutes in this state = //=-------------------------------------------------------------------------= //= Example "in.dat" file: = //= = //= BUSY, 2 = //= IDLE, 11 = //= BUSY, 5 = //= IDLE, 1 = //= IDLE, 2 = //=-------------------------------------------------------------------------= //= Example output (for above "in.dat"): = //= = //= 110000000000011111000 = //=-------------------------------------------------------------------------= //= Build: bcc32 interval2vector.c = //=-------------------------------------------------------------------------= //= Execute: interval2vector < in.dat = //=-------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (07/17/12) - Genesis = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() and feof() #include // Needed for atoi() and exit() #include // Needed for toupper() //=========================================================================== //= Main program = //=========================================================================== void main(void) { char state; // State ('B' or 'I') int numValues; // Number of values for state char inValue1[16]; // Value #1 read-in char inValue2[16]; // Value #2 read-in int i; // Loop counter while(1) { // Get input tuple fscanf(stdin, "%s %s \n", inValue1, inValue2); state = toupper(inValue1[0]); numValues = atoi(inValue2); // Generate vector values for (i=0; i