-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram176.c
56 lines (40 loc) · 946 Bytes
/
Program176.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
take input of character and string from user and
check weather the character is present in string or not
*/
#include<stdio.h>
#include<stdbool.h>
bool Count(char *str, char ch)
{
bool bFlag = false;
while(*str != '\0')
{
if(*str == ch)
{
bFlag = true;
}
str++;
}
return bFlag;
}
int main()
{
char Arr[30];
bool bRet = false;
char cValue = '\0';
printf("Enter string: \n");
scanf("%[^'\n']s" , Arr);
printf("Enter the character to be searched:\n");
scanf(" %C" , &cValue); // just specify single space to eliminate the error hya space mule buffer madhe urlela enter hota to nullify zala and the second char was accepted
bRet = Count(Arr , cValue);
if(bRet == true)
{
printf("present");
}
else
{
printf("not present");
}
printf("number of character: %d\n" , bRet);
return 0;
}