[Solved] How do I read a large file of numbers and store its content in an array?

fopen, calloc, and realloc can all fail, returning NULL. In the case of realloc, the original allocation will remain untouched, so immediately overwriting the original pointer with the newly returned value will leak memory and throw away potentially useful data. Reallocating every iteration is rather costly. A better strategy is to reallocate when the buffer … Read more

[Solved] Another coredump issue in C

I would think you would need to add check on your externally accepted values (using assert might be a start) Like : checking tm>0 ler>0 C[i]<tm A[i]!=NULL B[i]!=NULL As mentionned in the comment it an off by one issue : in LER the values should be from 0 to tm-1 or use B[i][j]=C[k]-1; at line … Read more