Hello. I'm just starting C++, but have scripted in other languages before. One of the things I aspire to do is to create an AI, but I recently ran into trouble while scripting it. What It's supposed to do follows:
1. Prompt the user to enter a filename.
2. Load the file.
3. Prompt the user to enter a phrase to teach the AI (until a better method is found).
4. Prompt the user to say something to the AI.
5. Take what the user said, and search the data file for a line with a similar phrase in it.
6. Print the line to the console, split at a period.
I'm getting several errors, and am not entirely sure if everything I'm doing will work, but am hoping someone can correct me. Thanks a lot in advance.
COPY AND PASTE INTO COMPILER:
using namespace std;
cin >> filename;
openfile.open(filename,ios::app|ios:ut); // opens the file for appending and outputting
cout << "Sorry, the program is experiencing errors, or the specified file does not exist. Please try again." << endl;
cout << "First teach the AI a new phrase to help the learning process. Please use periods and proper grammar." << endl;
cin >> teach;
openfile << teach << " "; // it appends what you said to the file, with a space
cout << "You taught the AI: " << teach << endl;
cout << "Please type something for the AI to process, then press enter." << endl;
cin >> usersaid;
char delim = "."; // the delimiter is periods
char line = usersaid; // the first 5 characters of what they said?
char response = getline(openfile,line,delim); // the string, "response", is the
// line in the file that contains the first 5 letters you said,
// but it only outputs from that spot to the next period
cout << "AI: " << response << " " << endl; // the output