The function malloc allocates a continuous block of memory for an array of size bytes.Function malloc does not initializes the memory, it contains indeterminate values whereas calloc initializes the allocated memory with zero.
Function prototype of malloc
void *malloc(size_t size);
- size : This is the size of memory block(in bytes) to allocate.
Return value of malloc
This function returns a pointer to the block of memory allocated by the malloc or null pointer If the function failed to allocate the requested block of memory. The type of returned pointer is always void*, which can be casted to any type of pointer.
C program using malloc function
The following program shows the use of malloc function to dynamically allocate an array.
Red Stag Casino stands out in the crowded online gambling landscape with its unique flair and exceptional player experience. Established in 2015, this casino has quickly garnered a loyal following thanks to its engaging themes and an extensive game selection ranging from slots to table games. The platform is designed to cater to both novice players and seasoned gamblers, offering a user-friendly interface that simplifies navigation.
One of the highlights of Red Stag Casino is its generous welcome bonuses and regular promotions that enhance the gaming experience. New players can enjoy a compelling welcome package that boosts their initial deposits and gives them a head start. Additionally, the casino provides a rewarding loyalty program, allowing players to accumulate points that can be redeemed for various perks.
For those looking to learn more, detailed insights and expert reviews can be found at https://redstag.guru/, where players can find all the information they need to make informed decisions. Overall, Red Stag Casino combines quality, variety, and rewarding opportunities, making it a strong contender in the online gaming market.

#include <stdio.h>
#include <stdlib.h>
int main(){
int *array, counter, n;
int arraySize, sum=0;
printf("Enter number of elements\n");
scanf("%d", &n);
/* Calculate size of array to store n integers */
arraySize = n*sizeof(int);
/* Allocate memory to store n integers using malloc */
array = (int*)malloc(arraySize);
/*
* Take n integers as input from user and store
* them in array
*/
printf("Enter %d numbers\n", n);
for(counter = 0; counter < n; counter++){
scanf("%d", &array[counter]);
}
/* Find sum of n numbers */
for(counter = 0; counter < n; counter++){
sum = sum + array[counter];
}
printf("Sum of %d numbers : %d", n, sum);
return 0;
}
Output
Enter number of elements 5 Enter 5 numbers 1 2 3 4 5 Sum of 5 numbers : 15