Let's talk about "Fu*k Pointers Days"

Hey there guys, do you still remember those days when you're learning pointers and saying "Fu*k this shit! Im going to be a fu*king stripper!" LOL!

What did you do to make yourself comfortable to this pointers? Can we share to each other our experience?
The only way I got used to pointer was through roughly a week of practice, practice, practice. Reading almost every resource available. Writing code that used them (wow, I have never seen the compiler shout so much).

Pointers are awesome, once you get the hang of them.
Good luck.
Once I hit my computer architecture class they made sense and I realized how simple they are.
closed account (o1vk4iN6)
I knew a bit of assembly before I actually started to even look at C/C++ so pointers were a relatively easy concept. Everything is in memory and to access anything you need addresses or you can call them pointers to know what memory you want to access. It's such a simplistic concept I don't really get how so many have trouble with it. Maybe they are just looking at it too abstractly.
closed account (N36fSL3A)
I thought they were useless then when I started working with SDL (A C library), I saw how pointers were used and started to realize their usefulness and used them very frequently.
closed account (o1vk4iN6)
So you've never allocated memory before ? oh boy :/.
closed account (z05DSL3A)
I had a good mental model of the memory in a computer and the book I had at the time did a very good explanation of computer memory prior to explaining pointers so I never had to much trouble with pointers.

It would seem that most of the people that have trouble understanding pointers can not relate it to something they do understand.
Pointers are not difficult: they are simply variables which hold a memory address, which is a number. They are different from regular unsigned integers in that their arithmetic rules are different, hence "pointer arithmetic".

What is confusing about pointers is how they are declared and used. Instead of simply using a "pointer" type as in:

pointer p;

you give the type that is pointed to and insert an asterisk in between that and the variable name as in:

int *pi;

This is done to hint what type of data you want to retrieve. It matters because different data has different sizes. If you use the "universal" pointer type void* you will find you need to cast it whenever you want to dereference it.

To make things worse, the asterisk * is reused as the dereference operator. This is probably what confuses people the most.
closed account (N36fSL3A)
xerzi what are you talking about?
I never had trouble understanding pointers - it was something where I read the page on this site and had an intuitive understanding of how they worked just from that.

As for new/delete, I started off in an environment where I was basically forced to put those all in one place anyway, so I was often shielded from the problems any other programmers faced with that. It gave me time to learn what the problems were and how to avoid them
In hindsight its so simple, a pointer is a pointer to a reference which is a reference to a space in memory, when I was a noob noob that was hard for some reason.

Im sure I will get myself into a pointery referency mess though
Topic archived. No new replies allowed.