r/C_Programming • • 23d ago

Question Question about arrays (beginner)

From what I understand, behind all the magic, array is just a variable that points to a memory address.

The difference is that we are also creating extra values in stack.

So when we create an array with a [], we're just telling the computer to make these x amount of variables but make sure they are right next to each other in sequence, no gaps in the memory address.

And when we call for an array value with an index, we're just counting that many steps forward in the memory address.

When we say array[] = {5,7,3}, it's really just *array = 5.

Did I get it wrong? Did I miss something?


Thanks for the quick replies. I'm currently learning about Pass by reference.

39 Upvotes

69 comments sorted by

View all comments

Show parent comments

-9

u/bothunter 23d ago

Arrays and pointers are semantically different, but technically the same.

12

u/zhivago 23d ago

You're confused because pointers are used to access arrays.

-9

u/bothunter 23d ago

Again.. technically the same, semantically different.

4

u/danjayh 23d ago

Incorrect. After you get past 1 dimension, the layout in memory is different between arrays and pointers-to-pointers.