pls help me

Discussion in 'C' started by Shilpa1, Apr 17, 2008.

  1. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    <CODE>
    /* strtok example */
    #include <stdio.h>
    #include <string.h>

    int main ()
    {
    char str[] ="- This, a sample string.";
    char * pch;
    printf ("Splitting string \"%s\" into tokens:\n",str);
    pch = strtok (str," ,.-");
    while (pch != NULL)
    {
    printf ("%s\n",pch);
    pch = strtok (NULL, " ,.-");
    }
    return 0;
    }
    </CODE>

    In the above example output is
    This
    a
    sample
    string

    Now I want to store "This" and "sample" into one String and 'a" and "string" into another string.How to do this?pls help me.
     
  2. bashamsc

    bashamsc New Member

    Joined:
    May 22, 2007
    Messages:
    51
    Likes Received:
    7
    Trophy Points:
    0
    Location:
    chennai
    In while use array to store This , a , sample and string . And after loop use strcat() function to store This and sample in a string and same for other.
     

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