In the C Programming Language, the ispunct function checks whether c is a punctuation character. Punctuation characters are considered to be all printing characters barring alphanumeric characters and space.
Syntax
The syntax for the ispunct characteristic in the C Language is:
int ispunct(int c);
Parameters or Arguments
c The value to take a look at whether or not it is a punctuation character. Punctuation characters are regarded to be all printing characters except alphanumeric characters and space.
Returns
The ispunct feature returns a nonzero cost if c is a punctuation personality and returns zero if c is no longer a punctuation character.
Required Header
In the C Language, the required header for the ispunct feature is:
#include <ctype.h>
Applies To
In the C Language, the ispunct characteristic can be used in the following versions:
ANSI/ISO 9899-1990
ispunct Example
/* Example using ispunct by TechOnTheNet.com */
#include <stdio.h>
#include <ctype.h>
int main(int argc, const char * argv[])
{
/* Define a temporary variable */
unsigned char test;
/* Assign a test punctuation character to the variable */
test = ',';
/* Test to see if this character is a punctuation character */
if (ispunct(test) != 0) printf("%c is a punctuation character\n", test);
else printf("%c is not a punctuation character\n", test);
/* Assign a non-punctuation character to the variable */
test = 'T';
/* Test to see if this character is a punctuation character */
if (ispunct(test) != 0) printf("%c is a punctuation character\n", test);
else printf("%c is not a punctuation character\n", test);
return 0;
}
When compiled and run, this application will output:
, is a punctuation character
T is not a punctuation character
Similar Functions
Other C functions that are comparable to the ispunct function:
isalnum feature isgraph characteristic isprint characteristic
Leave a Review