C Standard Library

C <ctype.h> - ispunct() Function

The C <ctype.h> 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 example below shows the usage of ispunct() function.

#include <stdio.h>
#include <ctype.h>
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
  printf("str contains: %s", str);   
  return 0;

The output of the above code will be:

str contains: Hello@ World@

❮ C <ctype.h> Library