/* Extracts sub-sequence (offset, length) with a low end effect */ void get_subsequence(char *fname, int *offset, int *length) { char dummy[MAX_LEN]; FILE *fp; /* Open file descriptor */ fp = fopen(fname, "r"); if (!fp) { fprintf(stderr, "An error occured while trying to extract sub-sequence from file: %s\n", fname); exit(0); } *length = -1; *offset = -1; while (fscanf(fp, "%s", dummy) != EOF) { if (strstr(dummy, "length") && (*length == -1)) { fscanf(fp, "%d", length); } if (strstr(dummy, "offset") && (*offset == -1)) { fscanf(fp, "%d", offset); } } /* Close file descriptor */ fclose(fp); }