Thread: strtok() variant

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    75

    strtok() variant

    Hi,

    char *VARIANTstrtok(char *s1, const char *s2)


    this function break string s1 into "tokens"--that is the string is broken into substrings, each terminating with a '\0', where the substring is the part of s1 that is after s2.

    For example:


    char s1[] = "this is the c forum,this is my thread."
    char s2[] = ","
    str = VARIANTstrtok(s1, s2)

    THe content of str should be: "this is my thread."

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    That's nice.
    Do you have a question?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    75
    yes. I'm sorry for the confusion, I forgot to write what I wanted because I was thinking about how to describe the function.

    Is there a function like that ?

    If not how could i implement this with other function? I don't think I can write this function, I would fail miserably.

    Thanks.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    75
    I think I got it.

    First I do
    a = strpbrk() to find the position where "," is found then
    then do
    strcpy(str3,str1+a+1);

    what do you think?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 05:48 PM
  2. trying to use strtok() function to parse CL
    By ohaqqi in forum C Programming
    Replies: 15
    Last Post: 07-01-2007, 09:38 PM
  3. converting string to integer, for further use
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 07-01-2005, 03:12 AM
  4. strtok tokenizing on spaces as well as my delimiter
    By snowblind37 in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2004, 12:39 AM
  5. Trouble with strtok()
    By BianConiglio in forum C Programming
    Replies: 2
    Last Post: 05-08-2004, 06:56 PM