Ich bin dabei, einen Chat-Bot zu erstellen, und ich experimentiere gerade an diesem Punkt. aber meine "wenn" -Befehle funktionieren nicht und wenn ich "moodToday" eingebe, springt es einfach direkt zum else-Befehl."if" und "else if" -Befehle funktionieren nicht in C++
(Großschreibung von „moodToday“ ist nicht der Fehler)
jede und alle Hilfe
#include <fstream>
#include <cmath>
using namespace std;
int main() {
char name[50], moodToday[50];
cout << "A few things you should know at this time..." << endl << "1. I can't process last names." << endl << "2. I can't process acronyms." << endl;
system("pause");
cout << endl << endl << "What is your name?" << endl;
cin >> name;
cout << "Hello " << name << "." << endl << "How are you today?" << endl;
cin >> moodToday;
//can't figure this out...
if ((moodToday == "sad") || (moodToday == "bad") || (moodToday == "horrible")) {
cout << "That's not good." << endl << "Why are you feeling " << moodToday << "today?" << endl;
}
else if (moodToday == "good") {
cout << "Great!" << endl;
}
else {
cout << "I'm sorry, I don't undrestand that feeling." << endl;
}
system("pause");
return 0;
}
Bitte schreiben Sie die vollständige Fehlermeldung –
Wichtiger Hinweis: Sie sind keine "Befehle", sie sind Flow-Control-Anweisungen oder allgemeiner gesagt, das ist eine 'if'-Anweisung mit einer' else'-Klausel. – tadman
Häufige Leute! 4 Antworten! Dies beweist, dass die Frage gut und interessant ist, auch wenn das Thema nicht komplex ist. Sollte das nicht ein paar Upvotes verdienen? – Christophe