int main() {
Population town;
int population;
int numBirths, numDeaths;
string city, intTest;
bool isValid = true;
do {
cout << "Enter name of city: ";
cin >> city;
getline(cin, city);
for (int i = 0; i < city.length(); i++) {
if (!(isalpha(city[i]))) {
isValid = false;
}
else {
isValid = true;
break;
}
}
} while(!isValid);
Its not properly checking to see if the input is a string or not. Not sure whats wrong with the code.
Aucun commentaire:
Enregistrer un commentaire