C programming ispunct ctype.h


In C programming the <ctype.h> ispunct function test if the character is a punctuation mark.Whether the character is considered as punctuation mark is dependent on the current locale setting.In “C” locale the default locale of the compiler all the ‘ispunct’ returns true for all the printing character for which neither ‘isspace’ nor ‘isalnum’ is true.The declaration of the function is given below.

int ispunct(int c);

Parameters:
c -The character to be checked if it is a punctuation mark.

Return type
int -Return non-zero value if the argument is a punctuation mark.

For “C” locale all the punctuation mark will range between the integer value [33 , 47] , [58 , 64] , [91 , 96] and [123 , 126].In other words all the digits and the Latin upper case and lower case and the control characters are not considered punctuation mark.

Code example

printf(“%d” , ispunct(‘{‘ ));

printf(“\n%d” , ispunct( ‘$’ ));

printf(“\n%d” , ispunct( ‘”‘ ));

printf(“\n%d” , ispunct( ‘?’ ));

printf(“\n%d” , ispunct( ‘A’ ));

printf(“\n%d” , ispunct( ‘ ‘ ));

printf(“\n%d” , ispunct( 10 ));

Output,

16
16
16
16
0
0
0


Related links

->C isalnum

->C isgraph

->C isprint

->C isspace

->C isupper