Why Dynamic Memory is Needed
📖 Scenario: Imagine you are building a program that stores names of students in a class. Sometimes the class size changes, and you don't know the number of students before running the program.
🎯 Goal: You will create a simple C program that uses dynamic memory to store student names. This will show why dynamic memory is needed when the amount of data is not fixed.
📋 What You'll Learn
Create a pointer to hold student names dynamically
Use
malloc to allocate memory for 3 student namesAdd a variable to store the number of students
Use a loop to assign names to the allocated memory
Print the stored student names
💡 Why This Matters
🌍 Real World
Programs often need to handle data that changes size, like user input lists or files. Dynamic memory helps manage this efficiently.
💼 Career
Understanding dynamic memory is essential for C programmers working on system software, embedded devices, or performance-critical applications.
Progress0 / 4 steps