The ispunct()
function checks whether or not the character passed to it is a punctuation character.
#include<ctype.h>
Following is the declaration of ispunct()
in C, where c
is the character to be checked:
int ispunct(int c);
The function returns an integer value.
If the integer returned is non-zero (true), it means c
is a punctuation character.
If the integer returned is zero (false), it means c
is not a punctuation character.
#include <stdio.h>#include <ctype.h>int main(){//first 5 characters are punctuation characterschar ch[] = {'$', '>', '@', '[', ',' ,' ', '\r', 'a', 'Z', '7'};int i = 0;while (i < 10) {if(ispunct(ch[i]))printf("Punctuation character.\n", ch[i]);elseprintf("Not a punctuation character.\n", ch[i]);++i;}return 0;}
Free Resources