THREAD: sprx parse by delimiter function
  1. 06-03-2018, 06:19 PM
    twistedkillas's Avatar
    twistedkillas
    I am error
    twistedkillas's Avatar
    twistedkillas
    I am error
    81
    Posts
    590
    Reputation
    Apr 2014
    NextGenUpdate
    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]
  2. 06-12-2018, 04:07 PM
    twistedkillas's Avatar
    twistedkillas
    I am error
    twistedkillas's Avatar
    twistedkillas
    I am error
    81
    Posts
    590
    Reputation
    Apr 2014
    NextGenUpdate
    man i figured someone would helped me by now :(