I am doing an assignment, in which I have a large text file (1gb). I am supposed to parse this text file and store it in a tree for some operations. The problem I am facing is the time it takes to completely parse the whole file. It takes about 40 min to completely parse the file. Can anyone please show me how to do it efficiently in a few minutes? My code is
int main()
{
FILE * file=fopen("data.txt","r");
char line[1000];
char *token;
while(fgets(line,1000,file)!=NULL)
{
token=strtok(line," ");
while(token!=NULL)
{
cout<<token<<endl;
token=strtok(NULL," ");
}
}
fclose(file);
return 0;
}