So im trying to read an entire text file using this function:
FILE *fp = fopen(path, "r");
fseek(fp, 0, SEEK_END);
int tamanioArchivo = sizeof(char) * ftell(fp);
fseek(fp, 0, SEEK_SET);
char* archivo = malloc(tamanioArchivo + 1);
fread(archivo, tamanioArchivo + 1, 1, fp);
//do something with archivo
fclose(fp);
free(archivo);
I debugged it and the problem seems to be on the fread line. It brings back the file and adds some garbage at the end. Any ideas what im doing wrong?