C Data Type Functions - C ispunct






Determines if a character is punctuation (decimal 32?47, 58?63, 91?96, 123?126).

Prototype

int ispunct( int ch );

Parameters

ch - character to classify

Return value

Non-zero value if the character is a punctuation character, zero otherwise.

Example


#include <stdio.h>
#include <ctype.h>
#include <locale.h>
 /*from  w ww. ja  v  a2  s  . co  m*/
int main(void){
    unsigned char c = '\xd7'; // the character ? (multiplication sign) in ISO-8859-1
    printf("In the default C locale, \\xd7 is %spunctuation\n",
           ispunct(c) ? "" : "not " );
    setlocale(LC_ALL, "en_GB.iso88591");
    printf("In ISO-8859-1 locale, \\xd7 is %spunctuation\n",
           ispunct(c) ? "" : "not " );
}

The code above generates the following result.