C ++ isgraph () - C ++ Standardbibliotek

Funktionen isgraph () i C ++ kontrollerer, om det givne tegn er grafisk eller ej.

isgraph () Prototype

 int isgraph (int ch);

De isgraph()funktion kontrollerer, hvis chhar en grafisk repræsentation som klassificeret ved den aktuelle C locale. Som standard er følgende tegn grafiske:

  • Cifre (0 til 9)
  • Store bogstaver (A til Z)
  • Små bogstaver (a til z)
  • Tegnsætningstegn (! "# $% & '() * +, -. /:;? @ () _` (|) ~)

Opførslen af isgraph()er udefineret, hvis værdien af ​​ch ikke kan repræsenteres som usigneret char eller ikke er lig med EOF.

Det er defineret i header-fil "> header-fil.

isgraph () Parametre

ch: Tegnet, der skal kontrolleres.

isgraph () Returværdi

Funktionen isgraph () returnerer ikke-nul-værdi, hvis ch er grafisk, ellers returnerer nul.

Eksempel: Hvordan fungerer isgraph () -funktionen

 #include #include using namespace std; int main() ( char ch1 = '$'; char ch2 = ' '; isgraph(ch1)? cout << ch1 << " has graphical representation" : cout << ch1 << " does not have graphical representation"; cout << endl; isgraph(ch2)? cout << ch2 << " has graphical representation" : cout << ch2 << " does not have graphical representation"; return 0; )

Når du kører programmet, vil output være:

 $ har grafisk repræsentation har ikke grafisk repræsentation

Interessante artikler...