Tag Archives: malloc

Malloc and Casting

In C, the malloc function is used to allocate memory. Its prototype is: void *malloc(size_t size);void *malloc(size_t size); It returns a void pointer (void *), which indicates that it is a pointer to a region of unknown data type therefore … Continue reading

Posted in Computer Science | Tagged , | 2 Comments

Allocation 2D arrays in C (and freeing memory)

By convention, when dealing with 2D array, the first dimension refer to the rows, and the second to the columns. To create a 2D array (double pointer) in C, you first create a 1D array of pointers (rows), and then, … Continue reading

Posted in Uncategorized | Tagged | Leave a comment