Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(void) {
- char string[250];
- char palavra[250];
- int a, b, tam, count = 0, i, j, aux=0;
- printf("Digite uma string de até 250 letras:\n");
- fgets(string, 250, stdin);
- printf("Digite uma palavra:\n");
- fgets(palavra, 250, stdin);
- //tam = strlen(string); // tamanho com funcao
- a=0;
- while(string[a] != '\0'){
- a++;
- }
- b=0;
- while(palavra[b] != '\0'){
- b++;
- }
- for(i = 0; i < a; i++){
- for(j = 0; j < b; j++){
- if(string[i]==palavra[j])
- count++;
- if(count==b)
- aux++;
- }
- }
- printf("A palavra %s foi repetida %d vezes na string", palavra, aux);
- return 0;
- }
Add Comment
Please, Sign In to add comment