Hey,
I am allocating a 2d array of char dynamically like this:
it refuses to let me not typecast calloc.Code:Params = (char **)calloc(NumParam, sizeof(char *)); for(i=0; i<NumParam; ++i) Params[i] = (char*)calloc(NameLengthP,sizeof(char));
Then I read in value into the array like so (It's a binary input file):
When I print the array using printf("%s", Params[i]), the strings are longer then allocated. and the output is:Code:for (i=0; i<NumParam; ++i) { j=0; do { fread(&Params[i][j], sizeof(char), 1, inp); j++; } while(Params[i][j] != ' ' && j<NameLengthP); }
instead of:Code:BARO ııııİİİİİİİİİİİİA V2201A00ıııı V4610M00ıııı SG ıııı ..........
Where is this leak coming from?Code:BARO V2201A00 V4610M00 SG



LinkBack URL
About LinkBacks


