>In order to set the value that a pointer points to, we dereference the pointer manually using the * operator. Inside of the method, t represents a pointer to a T value. By saying *t, we dereference the pointer t and we are able to access the value that t points to.
what
Zachary Brown
> not understanding how memory and pointers works.
kys.
Thomas Richardson
never going to make it
Robert Hill
You have some data. It is located in memory. Where it is located has an address i.e. a reference to your data.
This address is also data and can be stored in memory, at an address. This address is given a name (whatever you name your pointer variable)
You can access and/or alter data by dereferencing its address first to figure out where it is located in memory.
Hang in there senpai, you'll get there.
Owen Carter
I never got why it's called dereferencing though. Isn't it just referencing the memory location in the pointer?
Bentley Brown
The pointer (address) is the "reference", and dereferencing is "following the reference". It's somewhat unintuitive terminology.
Austin Turner
I didn't understand pointers for a long time and nothing anyone told me helped. Then eventually I figured it out and I don't really know why. So yeah, hang in there.
One thing: the syntax is good but it can be confusing at first. Even though we usually write int *a;, it makes more sense to think of it as int* a;. This defines a variable that can hold the address of an int (it can point to an int).
Anyway, keep looking at a bunch of diagrams with boxes and arrows, and keep looking at a bunch of code and writing a bunch of code that uses pointers.
Brayden Reyes
Not really. It's almost like a box with some tape to seal it. You organize your things (values) using these boxes so that they are easy to find, but you need to open them (dereference) in order to use your value.
Nolan Bell
What are you learning right now OP?
Austin Ortiz
best explanation/advice in thread, you musta a been a good dude to sit next to in class
Nolan Johnson
>thinking the concept of pointers is the problem here op is confused by the retarded terminology and excessively difficult explanation. Pointers work just the same as high-level variables except you can do math on the address itself, literally nobody could fail to understand pointers if explained in plain english instead of this academia bullshit
Jack Parker
Ah, I get it. Dereferencing isn't removing a reference, it's just accessing the value stored in a pointer. Thank you Cred Forums.
Samuel Butler
That's a shitty-ass explanation, makes you wonder if the person who wrote it even understood pointers
Brayden Foster
on that note, how does anyone fail to understand pointers, assuming theyre familiar with variables, how cpu and memory work, and their confusion is not simply cascading from not getting the */& syntax? nobody with that basic knowledge could fail to, and if they do that means they dont gave that knowledge yet so i wonder why theyre already trying c.
Matthew Watson
>all this confusion ITT because of C languages having such shitty overreliance on pointers with such shitty syntax oh am i laffin
Nicholas Carter
this
one of my old teachers used to say that if you cant explain something in simple terms to a layman, you dont understand it yourself. as irrational as that sounds, i find it to be true
note that that isnt the same as making the layman actually understand it, which is a problem that too easily lies with the layman
Luke Richardson
Why not call it access, open, check, basically anything that doesn't read like 'removed'? Fucken terminology.
Sebastian Collins
It's an explanation meant for someone who already understands it.
/* function: */
T value = 2; //some value. T *t = &value; //POINT t TO value. This is NOT a copy of value.
T copyVal = *t; //Get value (not the pointer -- what it points to) and store in copyVal.
*t = 5; //value is now 5. //copyVal is still 2.
Juan Mitchell
>why not call it access Consider Ada, if you will:
Some_Pointer : access Integer;
...
Some_Pointer := new Integer (7); Some_Pointer.all := 3;
...and so forth.
Kevin Howard
>basic knowledge Lacking in most CS courses. They're designed to churn out code monkeys, not humans who understand.
Joseph Russell
>that picture wtf am i looking at
Sebastian Fisher
Makes perfect sense tbqh
Noah Hill
...
Gabriel Brown
Mmm, Ada.
Blake Ortiz
"Dereference" seem like a confusing word to use for it if I'm understanding it correctly.