0
I need to make a simple search engine. Just open one arquivo.txt
, search for a desired word by the user, check how many times a word appears in the file and if it exists in the file. But this giving an error that did not identify the origin, similar to the absence of &
. Follows my code:
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#define max 500
int main(){
char pprocurada[100];
char *buff[500];
int contpp=0;
FILE *arq;
arq=fopen("C:\\Users\\jvict_000\\Desktop\\JoaoVictorF\\FaroesteCaboclo.txt", "r");
if(arq==NULL)
printf("n%co foi possivel abrir o arquivo\n",132);
printf("Digite a palavra a ser pesquisada\n");
fflush(stdin);
gets(pprocurada);
fflush(stdin);
fgets(*buff,max,arq);
while (!feof(arq)) {
if(contpp==0) {
strtok(*buff," ");
if(strcmp(pprocurada,*buff)==0)
contpp++;
} else {
strtok(NULL," ");
if(strcmp(pprocurada,*buff)==0)
contpp++;
}
fflush(stdin);
fgets(*buff,max,arq);
}
fclose(arq);
if(contpp!=0)
printf("Pesquisa terminada, a palavra %s foi encontrada: %d vezes",pprocurada,contpp);
else {
printf("A palavra %s n%co foi encontrada no arquivo",pprocurada,132);
}
return 0;
}
It would be interesting to inform the error message as well.
– rubStackOverflow
He says my executable program has stopped working.
– João Victor
It runs until asking for the desired word, when I put it, it says ".exe file has stopped working"
– João Victor
When you are
debugando
cannot capture the error?– rubStackOverflow
No ... :/ No solution to the problem
– João Victor