Hi all,
I'm really new to programming, but i understand many basics... I have tried to set myself a goal of creating a "smartbot" that can hold a somewhat intelligent conversation with someone. So far, i can get the bot to recognise a name of a person. I've been trying to put in a function that basically reads that whenever a user types in a "bad word" (i.e. a swear, or something stupid like ur mom), it will respond saying, "No, (insert name here), thats not appropriate..." So far I have this code, but it says I have a parse error (comment is there). Also, should i put this function seperate from others in a header file and have the program check constantly for such "bad words"? And lastly, is there a way I can put all the "bad words" in a text file and have it go through the text file instead of writing out ALL the bad words in code?
PS: Please excuse the swears in there, i'm just trying to protect against people trying to mess with my bot ;) Thank you in advance for any help...
EDIT: I have put stars instead of swears...
HEre is the code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string nameStr = ""; //Not necessary to initialize
string topicStr = "";
string t2 = "mom";
string t3 = "sex";
string t4 = "* *";
string t5 = "*";
string t6 = "**";
string t7 = "***";
string t8 = "****";
string t9 = "*****";
string t10 = "******";
cout << "Hi, my name is SMARTBOT... What's yours?" << endl;
getline(cin, nameStr);
cout << "Nice to meet you " << nameStr << ". What do you want to talk about?" <<endl;
getline(cin, topicStr);
if (topicStr == size_t find(t2)) //parse error!!!
cout << "I don't think so " << nameStr << ". That's pretty, innapropriate..." << endl;
else if (topicStr == "weather")
cout << "I haven't decided yet... Maybe we should check the weather channel or weather.com" << endl;
else if (topicStr == "nothing"||topicStr == "nothin"||topicStr == "notin")
cout << "Then why did you bother opening the application? Leave..." << endl;
else
cout << "Let me check my memory... hold on 1 sec" << endl;
system("PAUSE"); //this will pause the program so we can see what
//happened before exiting out
return 0;
}