Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Да се напише функција што ќе одредува колку пати даден знак се наоѓа вo даден стринг. Знакот за споредување и стрингот се внесуваат од тастатура
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #define MAX 101
- int countchar(char znak,char string[100])
- {/*
- int counter=0;
- while(*string!='\0')
- {
- if(*string==znak)
- ++counter;
- ++string;
- }
- */
- for(i=0<strlen(string);i++)
- {
- if(string[i]==znak)
- ++counter;
- }
- return counter;
- }
- int main()
- {
- char string[MAX];
- char znak;
- gets(string);
- scanf("%c",&znak);
- printf("%d",countchar(znak,string));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment