-
-
Save julian-klode/4a7611b0f7fa7c4dfa0e to your computer and use it in GitHub Desktop.
This file contains 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 <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