Hello, I'm fairly new to C++ and I'm constructing a program that defines a FSA, its states, accepting states, alphabet, and state transitions. The program will then go through a loop that will check the state transition and output ...accepted or ...not accepted. I want to be able to check for user input, so if the user inputs the alphabet "a", "b" for the FSA, it will give the message "Invalid Input!" and exit the program. I have this piece of code that checks this, but it only works if I use 1 character, if I use more than one char it won't work. I've been reading online and I've seen a couple of sources saying that if I use getline() that would help but I'm not sure I get how to implement it or if it applies to what I need. Any help is appreciated
1 2 3 4 5 6 7 8
for (m = 0; m < alphabet[m]; m++) {
if (input[m] == alphabet[m] || input[m] == alphabet[m+1]) {
continue;
}
else
cout << "Invalid Input!" << endl;
exit(0);
}