Check if a string contains another string (substring)

This is a discussion on Check if a string contains another string (substring) within the C Programming forums, part of the General Programming Boards category; hello everyone how can i check that a string contains another string(sub string), like: if i have a string like ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    39

    Post Check if a string contains another string (substring)

    hello everyone

    how can i check that a string contains another string(sub string), like:
    if i have a string like this:
    Code:
    GET /send.htm?Text=PAYLOAD+00500+11611
    and i want to check whether this string contains the word "PAYLOAD", and if it does do something.
    here the sub string would be "PAYLOAD".
    how can I do it?
    Last edited by Ali.B; 08-13-2009 at 05:48 AM. Reason: info added

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,312
    You can use strstr() from <string.h>.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    39
    could you show me how, with an example code or something ?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,312
    Yes
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    39
    wow nice ....
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 05:30 PM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 10:11 AM
  4. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  5. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21