good reason, i will delete the product and its dev from my machines and my mind.
1-
char **f = (char **)calloc(1, sizeof(char *));
this is like
char f[1][] and in loop accessing f[>0][] is accessing outside of allocated area try it yourself and get undefined behaviour .
2- i did not ask about calloc's functionality. i said what is the reason of making it all 0? in this context there is no reason for it.
0 - There is no one standard function call for dynamic memory allocation. If I want to use calloc, I use and want to delete it from your machine, it is your decision. 1 - Tell me what is the difference between this : char **f = (char **)calloc(1, sizeof(char *)); and this: char **f = (char **)malloc(1 * sizeof(char *)); 2 - You do not read what I wrote. He might want to be sure that all allocated memory starts with zero. Can you guarentee with that malloc? How do you know his requirements? Without req, you cannot say no reason for it.
Обсуждают сегодня