C Program to Store Data in Structures Dynamically

To understand this example, you should have the knowledge of the following C programming topics:


This program asks the user to store the value of noOfRecords and allocates the memory for the noOfRecords structure variables dynamically using the malloc() function.


Demonstrate the Dynamic Memory Allocation for Structure

Output

Enter the number of records: 2
Enter subject and marks:
Science 82
Enter subject and marks:
DSA 73

Displaying Information:
Science     82
DSA     73