ispunct() - Character Function

How is "ispunct()" used in C++?


ispunct() function is used to check whether the given argument is a punctuation character which includes all printing symbols except alphanumeric and space. It returns zero when the argument checked is not containing any of them.


int ispunct ( int c );

Example :

#include <stdio.h>
#include <cctype.h>
int main()
int n;
int count =0;
char str[]="Hello, welcome!";
for ( n=0 ; str[n]!='' ; n++)
printf ("Array has %d punctuations.\n", count);
return 0;

Result :

Array has 2 punctuations.

In the above example, this function is used to check the number of the specified character contained in a string array.

C++ Tutorial

Ask Questions

Ask Question