I am trying to do this but I stumbled with a strange bug can anyone shed light?

#include <acknex.h>
#include <default.c>
#include <strio.c>

STRING* tester="This is a test to check something.";


function getword(STRING* kelma)
{ int i;
int ii;
i=str_len(kelma);
ii=str_stri(kelma," ");
if(ii==0){return(kelma);}
str_trunc(kelma,i-ii);
return(kelma);
}
function removeword(STRING* kelmab)
{
int i;
i=str_stri(kelmab," ");
if(i==0){str_cpy(kelmab," ");return(kelmab);}
str_clip(kelmab,i);
return(kelmab);
}
function main()
{
STRING* kelma2="";
STRING* kelma3="";
STRING* kelma4="";
STRING* kelma5="";
str_cpy(kelma2,tester);
kelma4=getword(kelma2);
str_cat(kelma4," ");
str_cpy(kelma2,tester);
kelma5=removeword(kelma2);
error(kelma5); //<----------This should give same result
str_cpy(kelma2,kelma5);
error(kelma5); //<-----------As this why contents dissappear here?
while(str_len(kelma2)>0)
{
kelma3=getword(kelma2);
str_cpy(kelma2,kelma5);
kelma5=removeword(kelma2);
str_cpy(kelma2,kelma5);
str_cat(kelma4,kelma3);
str_cat(kelma4," ");
}
error(kelma4);
}

Last edited by Ercoles; 12/11/12 17:21.