How to allocate array using malloc

array
malloc

#1

I want to allocate arrays that can store 10**9 variables , how do I do it ?
Here’s how I’m doing ,think it’s not working
int *arr;
arr= (long long )malloc(100000sizeof(long long))
Anyone , any opinions/suggestions on this ?


#2

declare int arr as pointer array(*arr) then it will work


#3

Allocating memory to array using malloc is the way of dynamically allocating memory .
An example of a c programme to allocate memory to an integer array using malloc is given
#include<stdio.h>
int main()
{ int n;
printf(“Enter the size of array
“);
scanf(”%d”,&n);
int *array=(int )malloc(nsizeof(int)); //malloc syntax
return 0;
}