a shot of dev knowledge

Related tags

What is Calloc in C?

The calloc() function in C is used to allocate a specified amount of memory and then initialize it to zero. The function returns a void pointer to this memory location, which can then be cast to the desired type. The function takes in two parameters that collectively specify the amount of memory ​​to be allocated.

svg viewer


Take a look at the code below. Note how (int*) is used to convert the void pointer to an​ int pointer.


int main() {

    int* a = (int*) calloc(5, sizeof(int));

    return 0;

Related tags

View all Courses
Related Courses
Related Courses
View all Courses

Keep Exploring