C ispunct() Function Tutorial

  • Post author:
  • Post category:C

In this section, we will learn what the ispunct() function is and how to use it in C.

ispunct() function in C

The `ispunct()` function is used to check whether a character is a punctuation character.

Example of punctuation characters are:

?!,; etc.

The prototype of the function exists in the `ctype.h` header file and we need to include this header file in order to use ` ispunct ()` function.

ispunct() Function Syntax

Here’s the prototype of the ` ispunct ()` function:

int ispunct (int argument);

ispunct() Function Parameters

This function takes one argument and that is the character that we want to check.

ispunct() Function Return Value

The return value of the function is:

  • 0: If the character was not a punctuation-character.
  • Positive value: if the character was in fact a punctuation-character.

Example: using ispunct() function in C

#include <stdio.h>
#include <ctype.h>

int main() {

    char character = '?';
    char c2 = ';';

    printf("The first character: %d \nThe second character: %d", ispunct (character), ispunct (c2));

    return  0;


The first character: 16

The second character: 16

In this example, both characters are of punctuation types and so the result for both characters is a positive value.

Leave a Reply