文字列の大文字のみをチェックするために文字列を検証するにはどうすればよいですか?そして、それが大文字と小文字の両方を持っているかどうかをどうやってチェックしますか?あなたはそれが唯一の大文字を持っているかどうかを確認するために、文字列を検証するにはどうすればよい文字列のバリデーション
cout << "Enter state name or state abbr:" << " " << endl;
cin >> st;
if ((st == stateArray[in].getStateAbbr()) && (std::all_of(st.begin(), st.end(), isupper))) // uppercase only
{
cout << "Found. Your string is a state abbr." << endl;
}
else if ((st == stateArray[in].getStateName()))
{
cout << "Found." << " Your string is a state name" << endl;
}
else
{
cout << "Not found" << endl;
}
をあなたの質問?それは働いていないのですか?問題が何であっても、短い完全な例を強調表示することをお勧めします。 –
[良い質問をする方法を読む](http://stackoverflow.com/help/how-to-ask)に時間を割いて、[最小限の、完全で検証可能な例](http ://stackoverflow.com/help/mcve)。また、Eric Lippertの[小さなプログラムのデバッグ方法](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)を読んで、デバッガの使い方を学ぶことをお勧めします。 –
@RetiredNinjaステート名のために大文字と小文字が必要ですが、状態の省略にはすべて大文字である必要があります。 –