C_Algorithms 2.0.0
Documentation
Loading...
Searching...
No Matches
patternSearch.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdint.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include "patternSearch.h"
7
16uint32_t PatternSearch(char *text, char *pattern)
17{
18 uint32_t t = strlen(text);
19 uint32_t p = strlen(pattern);
20
21 for (uint32_t i = 0; i < t - p; i++)
22 {
23 uint32_t j;
24 for (j = 0; j < p; j++)
25 if (text[i + j] != pattern[j])
26 break;
27
28 if (j == p)
29 return i + 1;
30 }
31 return -1;
32}
uint32_t PatternSearch(char *text, char *pattern)
PatSearch is a Function to search for specific patterns in a text. (Be aware that its case sensitive!...