buenas señores del foro quisiera que me digan si esta bien lo que estoy haciendo necesito ller un archivo y despues teclear una cadena de caracteres para que se guarde lo que procesa a ver si le dan una ojeada
#include <cstdlib>
#include <iostream>
#include<conio.h>
using namespace std;
void Boyer_Moore_Matcher(char T[], char P[]);
void preBM(char P[], int bmNext[]);
int main()
{
freopen("salida.txt","w",stdout);
char cadena[100];
char patron[100];
cout<<"ingrese cadena"<<endl;
gets(cadena);
cout<<" ingrese patron a buscar "<<endl<<endl;
gets(patron);
Boyer_Moore_Matcher(cadena,patron);
fclose(stdin);
fclose(stdout);
system("pause");
}
void Mapers(char P[], int Arregloauxiliar[])
{
int M=strlen(P);
for(int i = 0; i <= 255; i++)
Arregloauxiliar[i] = M;
for(int i = 0; i < M; i++)
Arregloauxiliar[P[i]] = M - 1 - i ;
}
void Boyer_Moore_Matcher(char T[], char P[])
{
int N=strlen(T);
int M=strlen(P);
int i = M - 1;
int j = M - 1;
int Arregloauxiliar[255];//255 para tener todo el codigo ascci
Mapers(P,Arregloauxiliar);
while((i < N) && (j >= 0))
{
if(T[i] == P[j]){
i--;
j--;
}
else{
i += Arregloauxiliar[T[i]];
j = M - 1;
}
if(j < 0)
{
cout<<"Ocurrencia en -------->: "<<(i + 1)<<endl;
i += M + 1;
j = M - 1;
}
}
}