Hello guys,
I have to do a project for college in C in which i have to read an input of about 130k lines.
The lines are of this type:
"John F. Kennedy, George Washington, Thomas Jefferson, 1809
James Madison, James Monroe, John Quincy Adams, Andrew Jackson, 1829
Martin Van Buren, William Henry Harrison, 1841"
What I'm using is this:
int write (struct Node *node) {
char line[1024], author[1024];
char *token, *comma = ",";
FILE *p;
p = fopen ("test.txt", "r");
while (fgets (line, 1024, p) != NULL) {
token = strtok (linha, comma);
strcpy (author, token);
insert (&node, author);
memset (author, 0, sizeof (author));
}
showTree (node);
fclose (p);
}
and i know this only saves on the tree the first of each line, what i can't seem to figure out is how to to that for the rest of the lines, any thoughts on this?
P.S: Sorry for shit editing