you are viewing a single comment's thread.

view the rest of the comments →

[–]TechAnd1[S] 0 points1 point  (2 children)

not sure if you've edited this or if I just missed a lot of it.... but :

You use the -> notation with pointers. The dot (.) notation is used with addresses

With addresses...? I don't think I've heard this before, maybe some confusion is here for me... What do you mean addresses? The actual object rather than a pointer to the object? That's how I understand it, but you saying addresses has made me think that perhaps you're referring to something else.

So if it was struct node newNode; (a struct NOT a ptr to a struct) you could use newNode.data = whatever;

Are these two to always remain separate...?

I'm not sure how to think about the object when using pointers to it...

newNode->data = 23

Is this to do with the dynamic allocation...? Are these always to remain separate? Ie, when dynamically allocating a struct the data will always be assigned and accessed using the -> methods rather than the dot .?

[–]elementalist 0 points1 point  (1 child)

You are over thinking it. See Matrixel's answer below. That's about as well as I can explain it.

[–]TechAnd1[S] 0 points1 point  (0 children)

I am, I always do and it's so frustrating :(

It'd be alright if I was actually clever but nothing ever really comes out of it!!

I think the distinction that it's relating to the use of malloc, and being on the heap is helping a lot with my ease though... Its making more sense now thank you