calloc tag

2 questions


1 answers
99 views
0
What is the difference between malloc and calloc?

The method of using both is similar, and the size of the return is the same, but why is there a separate one?I can't tell the difference between the two.

1 years ago

1 answers
126 views
0
[C question] How should I release the dynamic allocation in this situation?

#include <stdio.h>#include <stdlib.h>char *Mystrrev(char *string) { int nLength = 0; char *Mystr = NULL; for(int i = 0; string[i] != '\0'; i++) nLength++; Mystr = (char*)calloc(nLength + 1...


© 2024 OneMinuteCode. All rights reserved.