My structure definition is,
typedef struct {
int taxid;
int geneid;
char goid[20];
char evidence[4];
char qualifier[20];
char goterm[
char mystring[100];
FILE *p = fopen ("gene2go.txt" , "r");
if (p == NULL) perror ("Error opening file");
else {
if ( fgets (mystring , 100 , pFile) != NULL )
puts (mystring);
pch = strtok (mystring, "\t");
while (pch != NULL)
{
//handle each token here and insert into struct
pch = strtok (NULL, "\t");
}
fclose (pFile);
}
return 0;
Refer to strtok, fgets