Hello, I have a problem of segment violation in the strcmp line.
First I use "guardaFichero" and when i try to search the string with the function "buscaFichero" it fails, can you help me please?
Code:
char *ficherosLeidos[NUMMAXINCLUDES];
...
void guardaFichero(char *fichero){
ficherosLeidos[numFich]=malloc(strlen(fichero)+1);
strcpy(ficherosLeidos[numFich],fichero);
printf("Agregado el fichero: %s\n",ficherosLeidos[numFich]);
}
....
int buscaFichero(char *fichero){
int i=0;
for(i=0;i<NUMMAXINCLUDES;i++){
if (strcmp(ficherosLeidos[i],fichero)==0) {
printf("Fichero repetido.\n");
return (1);
}
}
return 0;
}