What is isascii in c programming?
isascii in c checks the passed value is ascii character or not.
This function is defined in ctype.h header file.
This function returns non-zero digit if passed value is ascii character otherwise zero.
Prototype
int isascii(int a);
Parmeter
This function takes character as input parameter and converts it into ASCII value.
Return value
This function returns non-zero value if passed value is ascii character otherwise zero.
Example program for isascii function in c
#include<stdio.h>
#include<ctype.h>
int main()
{
char val='a';
if(isascii(val))
printf("This is ascii character \n");
else
printf("This is not ascii character \n");
return 0;
}
Code explanation
isascii function is called to determine whether the given input is ASCII or not. The result is being printed onto the console.
Difference between isascii and isalpha in c
isascii function checks the passed value is ASCII character or not. isalpha function checks the passed character is alphabetic or not.
Prototypes are as follows
int isascii(int a);
int isalpha(int a);
isascii in c | isalpha in c |
Checks the passed value is ascii character or not. | Checks the passed character is alphabetic or not. |
int isascii(int a); | int isalpha(int a); |
Write your own isascii function.
All valid ascii characters are from 0 to 127.
int own_isascii(int char)
{
return((char <= 127) && (char >= 0));
}
People also ask for
What is isascii in c?
isascii function checks the passed value is ASCII character or not. This function is defined in ctype.h header file.