r/AskComputerScience • • Feb 24 '26

Doubt regarding array

So i have started learning array since day before yesterday and a question is bugging me. I have not asked this question to anyone as they would think me as dumb (which i am). Here is the question.

Why do everyone say we need to create new array of more size if array fills up? Couldn't we just edit the size?

For example if int arr[4] is defined but we need to add a fifth element, couldn't we just edit out 4 to 5 in code itself and run it again?

I know the question is stupid but it doesn't make sense to me. This is my first time doing C. Previously i have only learned python. So please help me.

4 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/Etiennera Feb 26 '26

You can't use the next spot because it is taken up by an apache helicopter more like.

1

u/Todo_Toadfoot Feb 26 '26

The first DRM on a CD was defeated with a marker. It's good stuff!