Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void main(){
- int i=0, j, textLength, patternLength, match = 0;
- char text[100] = "3412894334012348621032803234567";
- char pattern[100]="234";
- //gets(text);
- //gets(pattern);
- textLength = strlen(text);
- patternLength = strlen(pattern);
- for( i = 0; i < textLength - patternLength + 1; i++){
- for(j=0;j<patternLength;j++){
- if( text[i+j] != pattern[j] ){
- break;
- }
- }
- if( patternLength == j ){
- match++;
- }
- }
- printf("Pattern Match %d times", match);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement