strdup(token) segfaulting is most
likely explained by
token being NULL.
(You don't need to strdup here anyway). Change
that piece of code to:
if ( token == NULL )
fprintf(stderr, "Invalid data in file.
exit(EXIT_FAILURE); // or some other error
tempID = atoi(token);
However a greater problem with the surrounding
code is that you are trying to use
strtok twice at once. It maintains
internal state and you can only have one
strtok "in progress" at any one time.
The second one cancels the first one. You'll have
to redesign that section of code.
is wrong, and your
the wrong number of bytes (although in the code
posted you never actually try to store anything in
that storage, so it would not cause an error just