#include <stdio.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#define BUFLEN (8 * 1024) | |
int main(void) { | |
FILE *fp; | |
FILE *fpout; | |
char line[100]; | |
char *id; | |
char *token; | |
char *buf = malloc(BUFLEN); | |
fp = fopen("infile", "r"); | |
setvbuf ( fp , buf , _IOLBF, BUFLEN ); | |
while (fgets(line, 100, fp) != NULL) { | |
id = strtok(line, "\t"); | |
token = strtok(NULL, "\t"); | |
char *fnout = malloc(strlen(id)+5); | |
fnout = strcat(fnout, id); | |
fnout = strcat(fnout, ".seq"); | |
fpout = fopen(fnout, "w"); | |
setvbuf ( fpout , NULL , _IONBF , 0 ); | |
fprintf(fpout, "%s", token); | |
fclose(fpout); | |
} | |
fclose(fp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment