Check if a character is present in the string or not
#include <stdio.h>
void present(char *c, char s)
{
char * ptr=c;
int count=0;
while(*ptr!='\0')
{
if(*ptr==s)
{
printf("The character %c is present in the string",s);
break;
}
else
{
printf("The character %c is not present in the string",s);
break;
}
ptr++;
}
}
int main(){
char s='w';
char str[]="anchalaggarwal";
present(str,s);
return 0;
}
Comments
Post a Comment