Thread: substring in C

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    substring in C

    say I have a string which always has a '\t' at the start of that string, how do I get all the string after that '\t' (tab)??

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    strtok(str, "\t") should do that - check for NULL returned, which means no \t was found.

    or strchr(str, '\t'), works the same way.

    --
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Add 1 to your string pointer in any reference to it.
    Mainframe assembler programmer by trade. C coder when I can.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. split string and remove substring
    By nyc_680 in forum C Programming
    Replies: 3
    Last Post: 03-02-2009, 04:45 AM
  2. I need help with creating a substring program
    By CProgramingBegg in forum C Programming
    Replies: 9
    Last Post: 02-06-2009, 09:50 AM
  3. longest common substring problem
    By Enchanter88 in forum C++ Programming
    Replies: 4
    Last Post: 09-29-2007, 11:02 AM
  4. Replies: 11
    Last Post: 12-11-2005, 11:50 PM
  5. Getting a substring help plz
    By joshua in forum C Programming
    Replies: 3
    Last Post: 11-01-2005, 06:11 PM