Test for a punctuation character.
Include
<ctype.h>
Prototype
int ispunct (int c);
Argument
c |
Return Value
Returns a non-zero integer value if the character, c
, is a
punctuation character; otherwise, returns zero.
Remarks
'!' '"' '#' '$' '%' '&' ''' '(' ')' '*' '+' ',' '-' '.' '/' ':'
';' '<' '=' '>' '?' '@' '[' '\' ']' '^' '_' '`' '{' '|' '}' '~'
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <ctype.h>
#include <stdio.h>
int main(void)
{
int ch;
ch = '&';
if (ispunct(ch))
printf("& is a punctuation character\n");
else
printf("& is NOT a punctuation character\n");
ch = '\t';
if (ispunct(ch))
printf("A tab is a punctuation character\n");
else
printf("A tab is NOT a punctuation character\n");
}
Example Output
& is a punctuation character
A tab is NOT a punctuation character