Hi,
Could anyone please explain this problem to me?
I use:
Code:
while(!feof(f))
{
fgets (all_id, 100 , f);
sscanf (all_id,"%*s %s %s",a_id,d_id);
str[i] = a_id;
printf("\n%s",str[i]);
strtok(a_id,"G");
ida = strtok (NULL, "G");
idsa[i]=atoi(ida);
i++;
}
printf("\n%s",str[2]);
Even if I use strncpy in place of strtok, the value retained by the str is the last value assigned to it using str[i]=a_id!
Why cannot the str retain its value outside loop?
I'll be obliged if anyone could explain this fundamental misconception of mine?
Thanks,
Angkar