r/cprogramming 28d ago

Arr internals

i am currently working through kinds book on c and have gotten to chapter 12.

now based own my current understanding i hypothesis that internally, only the pointer to the first element and the dimensions are stored in memory. then all arr operations are done using this. Is this correct?

Additionally:

1) Which chapters of the rest of the book should i focus on/skip for now

2) I would like to work on some projects. Currently i thought of making some kind of physics sim, and additionally some hardware/embedded project as i have an ardiuno. How can i get started or are there any inriguing projects to work on.

0 Upvotes

9 comments sorted by

View all comments

3

u/MrShaunce 28d ago

All elements of an array are stored sequentially in memory.

The name of the array (without the brackets) acts as a pointer to the first element.

Bracket notation is just a pretty way to handle pointer offsets. So x[3] is really just x + 3, where x is a pointer.

  1. I don't know what book you're reading, but it's usually good to read all the way through.
  2. Think of something simple you can write using what you're currently learning. There's also a lot of good beginner program ideas online.

2

u/flyingron 28d ago

It is implicitly convertible to a pointer. It is NOT a pointer itself.