test for any punctuation character
#include <ctype.h> int ispunct( int c );
The ispunct() function tests for any punctuation character such as a comma (,) or a period (.).
A nonzero value when the argument is a punctuation character, otherwise zero.
#include <stdio.h> #include <ctype.h> char chars[] = {'A', '!', '.', ',', ':', ';'}; #define SIZE sizeof( chars ) / sizeof( char ) void main() { int i; for( i = 0; i < SIZE; i++ ) { printf( "Char %c is %sa punctuation character\n", chars[i], ( ispunct( chars[i] ) ) ? "" : "not " ); } }
produces the output
Char A is not a punctuation character Char ! is a punctuation character Char . is a punctuation character Char , is a punctuation character Char : is a punctuation character Char ; is a punctuation character
ANSI
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), isspace(), isupper(), isxdigit()