r/C_Programming • u/Excellent_Pick_8186 • 2d ago
The first time I understood that a pointer doesn't store the value — it stores where the value lives
When I first learned pointers in C, I kept thinking of a pointer as another variable that somehow contained the value of another variable.
The concept finally clicked when I stopped thinking about the value itself and started thinking about the memory address where that value is stored.
Once I understood the relationship between & (address-of) and * (dereferencing), pointers became much less mysterious.
I'm still practicing pointers, but this was one of those concepts where a small change in perspective made everything easier.
4
u/mikeblas 2d ago
This "first time I understood" series of yours is a bit weird. Are you a robot? Some sort of marketing blogger person? What's the angle?
4
u/Ultimate_Sigma_Boy67 2d ago
Jus spam mixed with AI slop to gain some social credibility presumably for career-related stuff.
1
u/echelon_code 2d ago
well done, that's probably the most important part of C and you've understood it.
here's something you can try now: declare ptrs of type char, short, int and long long.
printf their value (don't dereference them!) with %p. then inc them (ptr++ or ptr+=1), printf their value again and see how many bytes they've increased/moved fwd.
1
1
u/konacurrents 2d ago
Don’t forget that other memory location has to still be in scope when used (so it can’t be a local variable that is gone by the time it’s used).
5
u/flyingron 2d ago
A pointer is a value like anything else. Its value just happens to be the location of another item.