C ++ iswgraph () - Bibliothèque standard C ++

La fonction iswgraph () en C ++ vérifie si le caractère large donné a une représentation graphique ou non.

La fonction iswgraph () est définie dans le fichier d'en-tête.

prototype iswgraph ()

 int iswgraph (wint_t ch);

La fonction iswgraph () vérifie si ch a une représentation graphique telle que classée par la locale C courante. Par défaut, les caractères suivants sont graphiques:

  • Chiffres (0 à 9)
  • Lettres majuscules (A à Z)
  • Lettres minuscules (a à z)
  • Caractères de ponctuation (! "# $% & '() * +, -. /:;? @ () _` (|) ~)

Paramètres iswgraph ()

  • ch: Le caractère large à vérifier.

iswgraph () Valeur de retour

  • La fonction iswgraph () renvoie une valeur non nulle si ch a un caractère de représentation graphique.
  • Il renvoie zéro si ch n'a pas de caractère de représentation graphique.

Exemple: comment fonctionne la fonction iswgraph ()?

 #include #include #include using namespace std; int main() ( setlocale(LC_ALL, "en_US.UTF-8"); wchar_t ch1 = L'u0009'; wchar_t ch2 = L'u03a9'; iswgraph(ch1)? wcout << ch1 << L" has graphical representation" : wcout << ch1 << L" does not have graphical representation"; wcout << endl; iswgraph(ch2)? wcout << ch2 << L" has graphical representation" : wcout << ch2 << L" does not have graphical representation"; return 0; )

Lorsque vous exécutez le programme, la sortie sera:

 n'a pas de représentation graphique Ω a une représentation graphique

Articles intéressants...