Thread: Need Advice For A Small C++ Program

  1. #1
    Registered User
    Join Date
    Nov 2011

    Need Advice For A Small C++ Program

    Hey, guys! I need y'alls help on this small, but kinda difficult program I been trying to make. I am trying to make a program where the user types in a question, such as, " Where do I make my account?".. and the program reads the user inputs and replies with a pre-written statement by keying on certain words such as " make" and/or "account" from the example sentence I just wrote above.. If any of y'all have used paypal before you might be aware of their "Virtual Chat Assistance" on their website. That is sort of what I am trying to make. Obviously, I need to use the function "string" to hold the user's input. But from there, I have no idea how to move on. What functions can I, or should I, use? I was thinking about maybe using the "if", "else if", and "else" statements. but after trying it in my program, it wouldn't even compile because... well I don't even know why, really.. haha. (No don't take me as a total newbie on using IF statements, because I have written many other programs using it, and it worked fine. It's just I have never written a program like this before. So anyway, how should I set up my "pre-defined words" and my "pre-written statements/replies"? And what can I do to make the program read the user's input, and pick out the keywords in it, and than reply with a pre-written statement that goes along with the certain keyword?

    I'm trying my best to explain this as detailed as possible, but forgive me if you don't really understand what I'm asking haha.

    If you do... than pls help me out! I will be greatly appreciative!

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    First you will probably need to split your user input into words. Try this and post any code you have problems with.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Hey, thanks for your comment! I really appreciate it! .. but I do have some concerns about what you said.

    How would I go about "splitting the user input into words"? I'm not sure what you mean by that.. I'm using the string function, so every word, punctuation, and space in the input is stored. So I guess my actual question is, what do I do from there? Or how would I go about? What functions can I use that would read the input stored in string and read each word, knowing each word is defined and has its own special properties, not as a whole sentence ? If you know what I mean? Like "char" for instance.. if you typed a whole sentence, and the place holder was a "char" not a string, it would only come up with the first letter. Or better yet, if the place holder was "char[256]" and you typed a whole sentence with no spaces, the whole sentence would come up, but the program thinks its just a huge word, not a sentence.

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    What you're trying, is very complicated if you expect it to understand English Grammar and respond accordingly ...( is AI !)
    Otherwise, you could first try to match whole input sentences and give exact answers .
    If that is too simple for you, do something like frequency count of the words..and give answers matching the keywords.

    >How would I go about "splitting the user input into words"? I'm not sure what you mean by that..
    That is called tokenizing.... and is necessary if you want to deal with the words individually. (Read up on stringstream `s)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with small C program
    By exus69 in forum C Programming
    Replies: 2
    Last Post: 10-01-2010, 01:52 AM
  2. Replies: 16
    Last Post: 09-21-2004, 11:08 PM
  3. A little Help with a small program
    By whtpirate in forum C Programming
    Replies: 7
    Last Post: 06-05-2003, 06:15 PM
  4. A small problem with a small program
    By Wetling in forum C Programming
    Replies: 7
    Last Post: 03-25-2002, 09:45 PM
  5. Help with a small program
    By nmbr1sun99 in forum C Programming
    Replies: 11
    Last Post: 02-12-2002, 12:30 AM

Tags for this Thread