Files
dotfile/.config/Code/User/History/-d0bf71b/cRZL.c
T
2024-09-15 22:10:50 +02:00

31 lines
492 B
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <stdio.h>
#include <string.h>
int naive(char *m, char *t){
int lt = strlen(t);
int lm = strlen(m);
int i = 0;
int res = 0;
while(i < lt){
if (strncmp(t, m, lm) == 0){
res += 1;
}
else{
i++;
t++;
}
}
return res;
}
int main(){
char* text = "blabablabalablaba" ;
char* mot = "bla";
int oc = 0;
oc = naive(mot, text);
printf("il y en a : %d\n", oc);
return 0;
}