IT HOME Programming care

IT HOME Programming Care

Thursday, November 17, 2016

User defined Function Check special characters exists in the input or not

/* User defined Function Check special characters exists in the input or not */

Function special_character_checker

//md. sohidul islam shoikat
int special_character_check(char *p)
{
n =0;

// strlen() will return the length of the string provided with parenthesis
for(i=0;i < strlen(p);i++)
{
if( *(p+i) >= 48 && *(p+i)<=57 || *(p+i)>=65 && *(p+i)<=90 || *(p+i)>= 97 && *(p+i)<=122 || *(p+i) == 32)
{
n++;
}

}
// Checking for the limit or size of the array
if(strlen(p)>15)
{
printf("\a\n\t\tERROR: LENGTH EXCEEDED BEYOND 15\n");
return 0;
}
if((*(p+0)==32||*(p+1)==32) && (strlen(p)==1||strlen(p)==2))
{
printf("\a\n\tERROR:FIELD CANNOT BE LEFT BLANK");
return 0;
}
else if(n!=strlen(p))
{
printf("\a\n\t\tERROR: NO SPECIAL CHARACTERS ALLOWED\n");
return 0;
}
else
{
return 1;
}

}

0 comments:

Post a Comment

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

IT HOME Freelancing Care