How to join the string after splitting

Discussion in 'C' started by spurthy04, Aug 4, 2011.

  1. spurthy04

    spurthy04 New Member

    Joined:
    Aug 4, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    HI,

    I have code where i've split the string "abc,cde,xyz" to abc cde and xyz using strtok.

    Now, I want to join it by adding single quote to each tokenised value.
    like 'abc','cde','xyz'.

    Can anyone help me ?

    Thanks,
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Code:
    sprintf(joined_string,"'%s','%s','%s'",str1,str2,str3);
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice