Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main()
- {
- char mot[100];
- char phrase[49] = "this is the l phrase that arisse going to useis";
- phrase[48] = '\0';
- scanf("%s", mot);
- int compteur = 0;
- int sizeword = 0;
- int sizephrase = 0;
- while(phrase [sizephrase] != '\0'){
- sizephrase++;
- }
- sizephrase++;
- while(mot [sizeword] != '\0'){
- sizeword++;
- }
- sizeword++;
- int j = 0;
- for(int i = 0; i < sizephrase - sizeword; i++){
- if(phrase[i] == mot[j]){
- j++;
- }
- if(j == sizeword - 1){
- compteur++;
- j = 0;
- }
- }
- printf("The number of appearances is %d\n", compteur);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement