What is ispunct in c programming?
ispunct in c checks whether the passed character is punctuation character or not.
Punctuation character is any graphic character.
It should not be an alphanumeric character.
This function returns non-zero digit if passed character is punctuation character otherwise zero.
This function is defined in ctype.h header file.
Prototype
int ispunct(int c);
Parameter
This function takes integer as input parameter.
Return value
This function returns non-zero digit if passed character is punctuation character otherwise zero.
Example program for ispunct function in c
#include<stdio.h>
#include<ctype.h>
int main()
{
int x='t';
if(ispunct(x))
printf("This is an punctuation character \n");
else
printf("This is not an punctuation character \n");
return 0;
}
Code explanation
ispunct function is called to check whether the passed character is a punctuation character or not. The result is being printed onto the console.
Difference between ispunct and isgraph in c
ispunct in c checks whether the passed character is a punctuation character or not. isgraph in c is used to find whether the passed character is graphical representable or not.
ispunct does not supports alphanumeric value. isgraph supports alphanumeric character.
Prototypes are as follows
int ispunct(int c);
int isgraph(int c);
ispunct function in c | isgraph function in c |
Checks whether the passed character is punctuation character or not. | Used to find whether the passed character is graphical representable or not. |
int ispunct(int c); | int isgraph(int c); |
People also ask for
What is the difference between ispunct and isalnum in c?
ispunct in c checks whether the passed character is a punctuation character or not. isalnum in c checks whether the passed character is alphanumeric or not. ispunct does not support alphanumeric characters.