C ++
 Computer >> コンピューター >  >> プログラミング >> C ++

C ++ STLのiswalpha()関数


C ++ STLのiswalpha()関数は、指定されたワイド文字がアルファベットかどうかを確認するために使用されます。

アルゴリズム

Begin
   Initializes the strings.
   Call function iswalpha(str) to check whether it contains alphabet or not.
   If it contains alphabet, then value will be returned otherwise zero will be returned.
End

サンプルコード

#include <cwctype>
#include <iostream>
#include <cwchar>
#include <clocale>
using namespace std;
int main() {
   setlocale(LC_ALL, "ab1234");
   wchar_t s[] = L"a%$^^&)";
   bool flag = 0;
   for (int i=0; i<wcslen(s); i++) {
      if (iswalpha(s[i])) {
         flag = 1;
         break;
      }
   }
   if (flag)
      wcout << s << L" contains alphabets";
   else
      wcout << s << L" doesn't contain alphabets";
   return 0;
}

出力

a%$^^&) contains alphabets

  1. C ++ STLのcosh()関数

    cosh()関数は、ラジアンで指定された角度の双曲線正弦を返します。これはC++STLに組み込まれている関数です。 cosh()関数の構文は次のとおりです。 cosh(var) 構文からわかるように、関数cosh()は、データ型float、double、またはlongdoubleのパラメーターvarを受け入れます。 varの双曲線コサインを返します。 C ++でcosh()を示すプログラムは次のとおりです- 例 #include <iostream> #include <cmath> using namespace std; int main() {  

  2. C ++ STLのsinh()関数

    sinh()関数は、ラジアンで指定された角度の双曲線正弦を返します。これはC++STLに組み込まれている関数です。 sinh()関数の構文は次のとおりです。 sinh(var) 構文からわかるように、関数sinh()は、データ型float、double、またはlongdoubleのパラメーターvarを受け入れます。 varの双曲線サインを返します。 C ++でsinh()を示すプログラムは次のとおりです。 例 #include <iostream> #include <cmath> using namespace std; int main() {