+ 1

Fix my codeing...

#include <stdio.h> #include<stdlib.h> int main() { typedef struct { int size; int *elements; int capacity; }dyn; dyn di; di.size = 2; di.capacity =1; di.elements = (*int)calloc(1*sizeof(int) ); if(di.elements != NULL) { printf("mem sucs size= %d capa = %d",di.size ,di.capacity ); } return 0; }

18th Mar 2022, 5:49 AM
Amala Yakin
2 Answers
+ 3
A cast to an integer pointer type is (int*), not (*int). calloc() also needs two parameters, with the first being the amount of elements, and the second being the size of each element. it would be calloc(1, sizeof(int)); in this case.
18th Mar 2022, 6:56 AM
Jerico Bote
Jerico Bote - avatar
0
It's crt
18th Mar 2022, 8:55 AM
Amala Yakin