That's strange... You declare str (line 77):
char str[200];
Then you apply strtok to trash values on str (since you didn't initialize it)... (line 79)
char * p = strtok (str, "|");
Then you use p without properly initiating the variable(line 101):
while (p) {
Maybe the problem is somewhere along there?
==============================================
EDIT:
First, it seems you are trying to save linea in str, so, you'll need to change str's declaration to this:
char str[LONG_MAX_LINEA];
Because you need to make sure that the destination string will have enough space.
Then you can't try to assign doing str[j] = linea; this is WRONG! So that line should be changed to:
strcpy(str,linea);
Second, theres no point in doing strtok to trash value, so change p declaration to:
char * p = NULL;
Then, before the while, you write:
p = strtok (str, "|");
Does it work now?