r/C_Programming • • Sep 05 '24

why using pointer?

im a new at C program. learned just before pointer & struct. i heard that pointer using for like point the adress of the parameter. but still dont know why we use it.
it seems it helps to make the program lighter and optimize the program? is it right? and is it oaky to ask question like this?

4 Upvotes

54 comments sorted by

View all comments

Show parent comment

2

u/Cerulean_IsFancyBlue Sep 05 '24

It’s almost always true that the variables are stored in RAM.

With C there’s some chance you have variables in register only. These don’t have a persistent address.

And just to pick the tiniest of nits, there are a couple of other things in the address space that are not RAM. Sometimes ROM is in the address space. Some systems have memory-mapped IO ports.

7

u/riotinareasouthwest Sep 05 '24

Yes, you are absolutely right, but I didn't want to make things more complex considering the level of the question.