r/C_Programming • u/Yelebear • Sep 14 '26
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.
View all comments
Show parent comment
1
u/bayesianparoxism Sep 15 '26
Arrays are not syntax sugar for pointers. But why argue with me when you can Google it and confirm it? This is not a matter of opinions or "optics".
A giveaway is sizeof operator yields different results for arrays and pointers.
Also you're mixing languages as C doesn't have classes (structs with methods).
I worked in compilers in the industry and also taught in uni. Of course, I don't dump all the intricacies of language implementations to my students, but I don't blatantly lie to them either.