What is ispunct() in C?
The ispunct() function checks whether or not the character passed to it is a punctuation character.
Punctuation characters in C
Library
#include<ctype.h>
Declaration
Following is the declaration of ispunct() in C, where c is the character to be checked:
int ispunct(int c);
Return value
The function returns an integer value.
If the integer returned is non-zero (true), it means c is a punctuation character.
If the integer returned is zero (false), it means c is not a punctuation character.
Code
#include <stdio.h>#include <ctype.h>int main(){//first 5 characters are punctuation characterschar ch[] = {'$', '>', '@', '[', ',' ,' ', '\r', 'a', 'Z', '7'};int i = 0;while (i < 10) {if(ispunct(ch[i]))printf("Punctuation character.\n", ch[i]);elseprintf("Not a punctuation character.\n", ch[i]);++i;}return 0;}
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved