Why dynamic memory is needed
📖 Scenario: Imagine you are creating a program that stores the 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 learn why dynamic memory is needed by creating a program that stores student names using dynamic memory allocation in C++.
📋 What You'll Learn
Create a pointer to store student names dynamically
Use
new to allocate memory for student namesUse a variable to store the number of students
Use a loop to input student names
Print all student names stored in dynamic memory
💡 Why This Matters
🌍 Real World
Dynamic memory is used in programs where the amount of data changes, like storing user input, files, or network data.
💼 Career
Understanding dynamic memory is important for software developers working with C++ to manage resources efficiently and avoid crashes.
Progress0 / 4 steps