Post: sprx parse by delimiter function
06-03-2018, 06:19 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); can someone help me with this parse function .. i want to split a string by delimiter then parse the text behind the # of the delimiter i choose


    
char *parsetheitem(char *stringz,int numb,char devider)
{
char tstring[100];
int LineNumber2 = 0;
for (int z = 0; z < sizeof(stringz); z++)
{
if (stringz[z] == NULL)
break;

if (stringz[z] == devider)
{
LineNumber2++;
if(LineNumber2==numb)
{
return tstring;
}

memset(tstring, 0, 100);
}
else
sprintf(tstring, "%s%c", tstring, stringz[z]);
}

}



Example

    
char* hhh ="wee|how|can|you|do|that";
char * keyp1 = parsetheitem(hhh,1,'|'Winky Winky;
char * keyp2 = parsetheitem(hhh,2,'|'Winky Winky;
char * keyp3 = parsetheitem(hhh,3,'|'Winky Winky;
char * keyp4 = parsetheitem(hhh,5,'|'Winky Winky;



Return

    
keyp1 = wee;
keyp2 = how;
keyp3 = can;
keyp4 = do

[/CODE]
06-12-2018, 04:07 PM #2
man i figured someone would helped me by now :(

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo