C Function to sort a string based on a delimiter

Discussion in 'C' started by mehimadri, Apr 7, 2012.

  1. mehimadri

    mehimadri New Member

    Joined:
    Apr 7, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I Need to write a function using C wherein I should do the following:
    (i) The function will receive a string in a character pointer
    (ii) This string will adhere to the following structure:
    "Kentucky+New York+Arizona+Nevada"
    The number of states can differ from 4 to 50
    The delimiter between States can differ from '+' to ',', hence I would like to pass
    the delimiter to the function.
    (iii) This string should then be sorted alphabetically from left to right.
    The above example would then become:
    "Arizona+Kentucky+Nevada+New York"
    (iv) This string needs to be returned from the function using a character pointer.
    Please help me in this.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck?
     

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