Thread: search a string

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    9

    search a string

    so i want to know how many "yy" in this string of characters "yyysadljhyysady"
    so how do i do this is c

    example would be nice

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    did you start by looking at the "string.h" header file? is there something in it to, say, find a substring?

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    As nadroj was hinting at, you can use strstr to find the first substring. Increment the pointer it returns and repeat until it returns NULL.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM