// Trying to read file
void readFilee(char *namefile){
FILE *f_in = fopen(namefile,"r");
char x;
int i = 0;
if(!f_in){ printf("Error"); exit(0); }
/* read to EOF */
while(1){
x = getc(f_in);
if(x == '\n') continue;
archivo[i] = x;
if(x == EOF) break;
i++;
}
tamArchivo = i;
fclose(f_in);
}
Fact that the error was f_in is null, but I do not understand why? I’m trying to connect a server with multiple clients, the clients are initialized waiting connection.
The command verificion “if” I get “Error”
add
after the while loop terminate. This will add null charachter at the end of your string
archivoalso may be the memory space of your
archivoarray is not sufficient to get the whole content of the file and so it could cause a buffer overflow so it could cause a crash