Created
October 2, 2011 19:16
-
-
Save impronunciable/1257799 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc,char *argv[]) { | |
int charcount = 0; | |
float timecount = 0; /* number of characters seen */ | |
FILE *in_file; /* input file */ | |
/* character or EOF flag from input */ | |
float f1,f2; | |
int ch,l; | |
char linea[1000], extr[1000]; | |
in_file = fopen(argv[2], "r"); | |
if (in_file == NULL) { | |
printf("Cannot open %s\n", argv[2]); | |
exit(8); | |
} | |
while(fgets(linea, 1000, in_file) != NULL){ | |
l = strlen(linea); | |
if(linea[l - 2] != '#'){ | |
sscanf(linea,"%f %f %s",&f1,&f2,extr); | |
charcount += strlen(extr) - 1; | |
timecount += f2 - f1; | |
} | |
} | |
printf("charcount: %d\t timecount: %f\n",charcount,timecount); | |
fclose(in_file); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment