Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library

The C++ <cctype> ispunct() function is used to check if the given character is a punctuation character. In the default "C" locale, a punctuation character are all those graphic characters (as in isgraph) which are not alphanumeric (as in isalnum).

Other locales may consider a different selection of characters as punctuation characters.


int ispunct ( int ch );               


ch Specify the character to be checked, casted to an int, or EOF.

Return Value

Returns non-zero value (i.e, true) if ch is a punctuation character, else returns zero (i.e, false).


The below example shows the usage of ispunct() function.

#include <iostream>
#include <cctype>
using namespace std;
int main (){
  char str[50] = "Hello, World!";

  //replacing all punctuation 
  //characters with @ in str
  int i = 0;
  while(str[i]) {
      str[i] = '@';

  //displaying the output
  cout<<"str contains: "<<str;  
  return 0;

The output of the above code will be:

str contains: Hello@ World@

❮ C++ <cctype> Library