Blog
20 BEST Audio Editing Software in 2021 [Free/Paid]
Audio editing software is a program that allows making changes in audio data. This program will...
The calloc() in C is a function used to allocate multiple blocks of memory having the same size. It is a dynamic memory allocation function that allocates the memory space to complex data structures such as arrays and structures and returns a void pointer to the memory. Calloc stands for contiguous allocation.
Malloc function is used to allocate a single block of memory space while the calloc function in C is used to allocate multiple blocks of memory space. Each block allocated by the calloc in C programming is of the same size.
ptr = (cast_type *) calloc (n, size);
Whenever there is an error allocating memory space such as the shortage of memory, then a null pointer is returned as shown in the below calloc example.
The below calloc program in C calculates the sum of an arithmetic sequence.
#include <stdio.h>
int main() {
int i, * ptr, sum = 0;
ptr = calloc(10, sizeof(int));
if (ptr == NULL) {
printf("Error! memory not allocated.");
exit(0);
}
printf("Building and calculating the sequence sum of the first 10 terms \ n ");
for (i = 0; i < 10; ++i) { * (ptr + i) = i;
sum += * (ptr + i);
}
printf("Sum = %d", sum);
free(ptr);
return 0;
}Building and calculating the sequence sum of the first 10 terms Sum = 45
Audio editing software is a program that allows making changes in audio data. This program will...
Dailymotion is a popular platform for watching videos online. Because of network connectivity or...
Following are frequently asked questions in interviews for freshers as well as experienced Java...
An eCommerce platform is a software application that helps online businesses to manage their...
Video players are a kind of media player that can play video data from varieties of sources local...
Shell Scripting Shell Scripting is an open-source computer program designed to be run by the...