c - What if the counter exceeds the memory allocated by malloc or calloc -
i utilize next command in c allocates 80 bytes (in 64bit system) d.
double *d = calloc(10, sizeof(double)); and using next loop initialize d
for (k=0;k<11;k++){ d[k] = k; } when run program, there no error. sense since upper limit on k 11, there should wrong d array of length 10. please allow me know why programme executed no error. in advance.
this undefined behavior. there might error, , might silently ignored os, when break rules - bets off.
what happens in code depends on os, compiler , architecture run on, might tolerant violation, crash or else, point - resulting behavior undefined.
c
No comments:
Post a Comment