PandA-2024.02
kmp_test.c
Go to the documentation of this file.
1 #include "kmp.h"
2 #include <string.h>
3 #include "TR.h"
4 
5 int main(){
6  char *y = "bull";//moose";
7  //char randomletter =
8  FILE *f = fopen("TR.txt", "r");
9 /*
10  fseek(f, 0, SEEK_END);
11  long pos = ftell(f);
12  fseek(f, 0, SEEK_SET);
13  printf("%dpos\n\n", pos);
14  char *bytes = malloc(pos);
15 
16  fread(bytes, pos, 1, f);
17  fclose(f);
18  */
19  int j;
20  int outs;
21  outs = 0;
22  int i;
23 
24  char x[STRING_SIZE];
25  for(j=0;j<STRING_SIZE;j++){
26  x[j] = 'a';
27  }
28 // for(i=0; i < STRING_SIZE; i++){
29 // fscanf(f, "%s", &x);
30 // }
31 
32 
33 
34  for(j=0;j<STRING_SIZE;j++){
35  // printf("%c", tr[j]);// = bytes[j];
36  }
37 
38  //char y[STRING_SIZE];
39 
40  for(i=0;i<PATTERN_SIZE;i++){
41  //y[i] = 'A';//+ (random() % 26);
42  //printf("%c", y[i]);
43  }
44 
45  //for(i=0;i<STRING_SIZE;i++){
46  //x[i] = 'A' + (random() % 26);
47  //outs[i] = 0;
48  //}
49 
50  outs = kmp(y, tr);
51 
52  //for(i=0;i<STRING_SIZE;i++){
53  // if(outs[i] > 0)
54  printf("outs = %d \n",outs);
55  //}
56 
57  return 0;
58 }
int main()
Definition: kmp_test.c:5
#define STRING_SIZE
Definition: kmp.h:11
#define PATTERN_SIZE
Definition: kmp.h:10
int kmp(char pattern[PATTERN_SIZE], char input[STRING_SIZE], int32_t kmpNext[PATTERN_SIZE], int32_t n_matches[1])
Definition: kmp.c:24
char tr[16206]
Definition: TR.h:1
x
Return the smallest n such that 2^n >= _x.

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13