Ok. I simplified the code down a lot to something manageable. Here's the problem. You see this code posted below? Well pretend the array char* p[50] contains three strings. the first element in the array is "ho" the second is "ha" and the last one is "he"
Now when I first print p[1] (the second element in the array) it prints "ha" and only "ha", but when I print p[1] for the second time it prints "ha he" (both the second and third element. Does anyone know why this is?
if you have to assume the variable word is an integer that starts off at the value 3
[php]
cout<<"p[1] " << p[1];
while(words > 0)
{
strcpy(init_str, str);
temp = strtok(init_str, " \"");
while(temp != NULL)
{
if(!strcmp(p[words-1], temp))
{
cout<<"eliminating redundancy";
temp = strtok(NULL," \"");
continue;
}
cout<<p[1];
temp = strtok(NULL," \"");
}
words--;
}
[/php]
Thanks in advance everyone. I could really use some help on this. Been scratching my head trying to figure this mess out for weeks, and I finally get it to the point where it should work, except its screwing up, because of this....