Live data from Hacker News

The 5-minute Guide to C Pointers

denniskubes.com

71–75 of 75 posts

Re: The 5-minute Guide to C Pointers

#72
post #55
post #42

Earlier quoted context omitted.

My first programming language where I used pointers was 68000 and they were easy for me to grasp, but for some reason it was harder when I started using C and everytime I get back to C or C++ I need a little refresher. For me it is the syntax used by C for pointers that makes it confusing.

> For me it is the syntax used by C for pointers that makes it confusing. Personally I don't see much difference between * (C way), ^ (Pascal way) or ref (Algol way). Or do you mean the declaration order ? int* ptr; (right to left) ptr = ^Integer /ref int ptr (left to right)

Yes, it is probably the declaration order which confuses me.

Re: The 5-minute Guide to C Pointers

#73
post #52

> The * operator is used to both declare a pointer variable and to dereference a pointer depending on where it appears. You seem to be suggesting that this is an inconsistency, it isn't: int *ptr; means that (*ptr) is of type ptr. *ptr = 3; Means the same and affect 3 to (*ptr)

Don't you mean (*ptr) is of type int ?

yes, of course.

Re: The 5-minute Guide to C Pointers

#74

Earlier quoted context omitted.

To me your line of code seems a bit too clever and complicates the concept of pointers. But we all learn differently so it's cool if it flips a switch for people who are, perhaps, more philosophical than I. I tend to use more boring examples like a card catalog vs a book when I'm explaining the idea of pointers.

Why do you say its clever/complicated? The example he mentioned seems like a fairly basic example of a pointer.

well mainly because it uses a kinda abstract/poetic concept that to explain something concrete. In order to understand the example you have to understand the little puzzle about the moon & the finger as well. Maybe I do understand the saying fully - maybe I don't fully understand the depth of that saying..? Now I'm confused about both!

Also using the term moon & luna. Are they the meant to be the thing? Where was luna mentioned in the saying? Is luna representing the moon?

Re: The 5-minute Guide to C Pointers

#75

Earlier quoted context omitted.

Why do you say its clever/complicated? The example he mentioned seems like a fairly basic example of a pointer.

well mainly because it uses a kinda abstract/poetic concept that to explain something concrete. In order to understand the example you have to understand the little puzzle about the moon & the finger as well. Maybe I do understand the saying fully - maybe I don't fully understand the depth of that saying..? Now I'm confused about both! Also using the term moon & luna. Are they the meant to be the thing? Where was lun…

I agree that the buddhist saying confused me at the start..

For the moon vs luna thing: For the line to be valid, 'moon' must be a datatype in C, so it can't be the name of the variable. It also makes sense literally because moon is a generalized body orbiting a planet whereas luna refers specifically to earths moon.

Post reply on HN