Thread: searching input

  1. #1
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60

    Post searching input

    I am creating a program kind of like a chat bot. I am here to ask how I would go about searching user input.. say the user asks the bot, "How are you doing?"
    I want to to a search for key words that would let me know what is being said how I would properly respond to such a question, so I would search the input for question words, such as what, how, when, where and I would also want to do a search for a question mark, so I know it is a question.. Do you understnd what I am talking about? Please help out if so =)

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    There's a function called strstr() in <cstring> that searches for a word in a string and gives a pointer to the first occurrance....

    Therefore if you wanted to test for the word "dinner"

    Code:
    char mystring[] = "It's dinner time";
    if(strstr(mystring,"dinner")!=NULL)
       cout << "dinner was present";
    Does that help?

  3. #3
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60
    that helps a lot. Thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input class project (again)
    By Elysia in forum C++ Programming
    Replies: 41
    Last Post: 02-13-2009, 10:52 AM
  2. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  3. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  4. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM