Alternative to Malloc in C

Joined
May 3, 2022
Messages
1
Reaction score
0
I have been learning C I am at the point were I am learning about malloc() and free() When I came across this article entitled Alternative of Malloc in C....

// C Program to implement Alternative to Malloc

// Importing standard input output file
#include <stdio.h>

// Main driver method
int main() {
// Alternative of Malloc '' operator refers
// to address of array memory block
intfirst_array = (int[2]){};

// Creating and initializing array together

// Custom input element at array indices
first_array[0] = 10;
first_array[1] = 20;

// Printing the array indices as passed in argument
printf("%d %d", first_array[0], first_array[1]);
return 0;
}

Can someone explain the int *first_array = (int[2]){}; to me in more detail please.
the original article is here: https://www.geeksforgeeks.org/alternative-of-malloc-in-c/ and is example 3 at the bottom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top