Here's what I have:
#include <iostream>
using namespace std;
int main() {
string name;
cout << "Customer name: ";
cin >> name;
if (name != "") {
//stuff omitted
} else if (name.empty()) {
cout << "You must enter a customer name.";
}
return 0;
}
As shown, I want to be able to accept an empty string to output an error when an empty string is inputted. The problem is that the program does not take an empty string; the terminal simply waits for input if I hit enter without typing anything, so the error message is never triggered. How do I make the program take an empty string?