0

[RE_UNSOLVED]my program is not able to read data from file on pc , its just printing bunch of zeros when testing the input

here is link to the code https://code.sololearn.com/csnflWnRafOK

25th Feb 2018, 6:32 AM
Hridyansh Thakur
Hridyansh Thakur - avatar
1 Answer
0
Your "fprintf(fp,"%f",*(ptr+i))" is printing unused memory. ptr 1 is set to the address of an empty heap location for a float integer. You are incrementing the unit of the memory location and printing more "0"s or unused memory. It explains why you see a bunch of 0s instead of floats. The memory calloc for ptr 1 is not stored to anything, alternately making it assigned 0 or false. If you meant to either use the value of the pointer incremented or you are creating a pointer notation of floats, make sure you are storing data.
14th Jul 2018, 12:39 AM
MeeoSlammer