Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Sunday, February 6, 2011

How to use ctype.h functions

The following codes shows how to use isdigit(), isalpha(), isalnum(), isxdigit(), isspace(), iscntrl(), ispunct(), isprint(), isgraph(),
#include<stdio.h>
#include<ctype.h>
int main()
{int i;
char f;
printf("enter character\n");
scanf("%c",&f);
i=isdigit(f);
if(i==0)printf("not digit\n");else printf("is digit\n");
i=isalpha(f);
if(i==0)printf("not alpha\n");else printf("is alpha\n");
i=isalnum(f);
if(i==0)printf("not digit or aplha\n");else printf("is digit or alpha\n");
i=isxdigit(f);
if(i==0)printf("not xdigit\n");else printf("is xdigit\n");
i=isspace(f);
if(i==0)printf("not space\n");else printf("is space\n");
i=iscntrl(f);
if(i==0)printf("not cntrl\n");else printf("is cntrl\n");
i=ispunct(f);
if(i==0)printf("not punct\n");else printf("is punct\n");
i=isprint(f);
if(i==0)printf("not print\n");else printf("is print\n");
i=isgraph(f);
if(i==0)printf("not graph\n");else printf("is graph\n");
}

No comments:

Post a Comment

Related Posts with Thumbnails