C ++ isgraph () - C ++ Standardbibliotek

Funktionen isgraph () i C ++ kontrollerar om det angivna tecknet är grafiskt eller inte.

isgraph () Prototyp

 int isgraph (int ch);

De isgraph()funktions kontrollerar om chhar en grafisk representation som klassificerats av den aktuella C-språk. Som standard är följande tecken grafiska:

  • Siffror (0 till 9)
  • Versaler (A till Z)
  • Små bokstäver (a till z)
  • Punktstecken (! "# $% & '() * +, -. /:;? @ () _` (|) ~)

Uppförandet av isgraph()är odefinierat om värdet på ch inte kan representeras som osignerad röd eller inte är lika med EOF.

Det definieras i rubrikfil "> rubrikfil.

isgraph () Parametrar

ch: Karaktären att kontrollera.

isgraph () Returvärde

Funktionen isgraph () returnerar ett värde som inte är noll om ch är grafiskt, annars returnerar noll.

Exempel: Hur fungerar 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ör programmet blir resultatet:

 $ har grafisk representation har inte grafisk representation

Intressanta artiklar...