Substrings

This is a discussion on Substrings within the C++ Programming forums, part of the General Programming Boards category; Hello: How can I search one input string for two substrings? This does not work: Code: #include <stdio.h> #include <fstream> ...

  1. #1
    random number generator reRanger's Avatar
    Join Date
    Oct 2004
    Posts
    44

    Substrings

    Hello:
    How can I search one input string for two substrings?



    This does not work:

    Code:
    #include <stdio.h>
    #include <fstream>
    #include <iostream>
    #include <string.h>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
    char resp1[]="good,no"; 
    char name[256];
    
    
    char resp[]="not";//-Check*
    char name1[256];//-Check*
    
    
    cout<< "Hello, how are you today?\n"<< endl;                     
    cin.getline (name,256);
    
    
    
    
    
    
    char * pch;
    pch=strstr (name, "good"); //Searching for “good” in  ^ Char str
    if(pch !=NULL) 
    
    
    
    
    
    
    char * pch;//-Check*
    pch=strstr (name1, "not"); //Searching for “good” in  ^ Char str//-Check*
    if(pch !=NULL)
    
    
    
    {
    cout<< "I am glad to hear you are doing well today.\n"<< endl;                     
    else
    cout<< "Is anything wrong at all? Would you like to discuss it? \n"<< endl;                      
    }
    
    
    
    Sleep(50000);
    
    return 0;  //END
    
        }
    Last edited by reRanger; 11-28-2004 at 12:15 PM.
    "Nay! But you love the present life!"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help, extracting substrings from a string
    By doubty in forum C Programming
    Replies: 1
    Last Post: 06-18-2009, 12:57 AM
  2. vector of substrings
    By manav in forum C++ Programming
    Replies: 47
    Last Post: 05-10-2008, 03:05 PM
  3. Searching for a series of possible substrings inside a string
    By andrew.bolster in forum C Programming
    Replies: 7
    Last Post: 02-10-2008, 02:20 AM
  4. substrings
    By arjunajay in forum C++ Programming
    Replies: 30
    Last Post: 06-10-2005, 10:13 PM
  5. Searching strings - substring's
    By Vber in forum C Programming
    Replies: 4
    Last Post: 02-06-2003, 12:05 PM

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