سلام دوستان
نمی توان در کدویزن آرایه بدون سایز تعریف کرد ؟ چه شکلی ؟ :mrgreen:
نمی توان در کدویزن آرایه بدون سایز تعریف کرد ؟ چه شکلی ؟ :mrgreen:
void *malloc(size_t size);
/* Allocate space for an array with ten elements of type int. */
int *ptr = malloc(10 * sizeof (int));
if (ptr == NULL) {
/* Memory could not be allocated, the program should handle the error here as appropriate. */
} else {
/* Allocation succeeded. Do something. */
free(ptr); /* We are done with the int objects, and free the associated pointer. */
ptr = NULL; /* The pointer must not be used again, unless re-assigned to using malloc again. */
}
دیدگاه