When trying to execute this piece of code, the program craches when it reaches free(zin). When I remove the free(zin), everything works well, but I think it's better to free the allocated memory. Does anyone know what I'm doing wrong ?
Code:void readFile(){ FILE *f; char *zin, *tag; if ( !(f = fopen("test.txt", "r")) ) return; zin = malloc(sizeof(char)); while (fgets(zin, SKY_MAX_ZIN_SIZE, f) != NULL){ tag = fileZoekTag (zin); fileProcessTag(tag); } free (zin); fclose(f); }