Posted By: Domino
extract characters from a string - 03/21/23 19:23
I have a 4 character and I wish to know what is the third character.
How di I extract a give character(s) ( character 3 or 4 to 5). Must be a function.
Posted By: Grant
Re: extract characters from a string - 03/21/23 20:19
Look for the strmid() function
Posted By: VoroneTZ
Re: extract characters from a string - 03/21/23 20:22
function GetChar(STRING* Astr, STRING* Aresult, int Anum) // Source, Result, Index of character
{
str_cpy(Aresult,(Astr.chars)[Anum]); //get 3rd char (i dunno why we have 4th char too)
str_trunc(Aresult,str_len(Aresult)-1); //delete all chars, except 1st
}
<...>
STRING* fstart="1234";
STRING* fresult="";
GetChar(fstart,fresult, 3); //copy 3rd char to fresult
printf(fresult.chars); // print result
<...>