C ispunct () - Bibliothèque standard C

La fonction ispunct () vérifie si un caractère est un signe de ponctuation ou non.

Le prototype de fonction de ispunct()est:

 int ispunct(int argument);

Si un caractère passé à la ispunct()fonction est une ponctuation, il renvoie un entier différent de zéro. Sinon, il renvoie 0.

En programmation C, les caractères sont traités comme des entiers en interne. C'est pourquoi ispunct()prend un argument entier.

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

Exemple 1: programme de vérification de la ponctuation

 #include #include int main() ( char c; int result; c = ':'; result = ispunct(c); if (result == 0) ( printf("%c is not a punctuation", c); ) else ( printf("%c is a punctuation", c); ) return 0; )

Production

 : est une ponctuation 

Exemple 2: imprimer toutes les ponctuations

 #include #include int main() ( int i; printf("All punctuations in C: "); // looping through all ASCII characters for (i = 0; i <= 127; ++i) if(ispunct(i)!= 0) printf("%c ", i); return 0; ) 

Production

Toutes les ponctuations en C:! "# $% & '() * +, -. /:;? @ () _` (|) ~

Articles intéressants...