News for hackers. Stuff that matters.
Re:C Primer by scandox on Friday May 04, 2018 @10:03AM (#16994679)
Whenever I was trying to learn C (and as ever making small bits of progress), what I always wanted was a great visualisation system for pointers. I've seen various attempts at this online but I've never really found something that felt intuitive. I think a good on-paper means of reasoning about pointers would be a huge help in becoming fluent in C.
Re:C Primer by ryl00 on Friday May 04, 2018 @11:11AM (#16995143)
What about this analogy? You have a piece of paper with a street address on it (the pointer value). You go to that street address (derefence the pointer), open the mailbox, and inside is another piece of paper with what you're actually looking for (like someone's name). For pointers to pointers, add another level of indirection..
Re:C Primer by vram22 on Friday May 04, 2018 @01:51PM (#16996620)
And after you've learned that (basics of pointers in C), a nice quick test of your knowledge (but not a comprehensive one) can be to read this standard declaration of main() in C (based on ANSI C, BTW, as described in 2nd edition of K&R C book, not sure if changed in later versions of standard):

  int main(int ac, char **av)
and then try to figure what the following mean (what type they are, and whether each of them is a pointer or a pointed-to thing, or both:

  av

  *av

  **av

  av[0]
etc.

I was once teaching a class on C to a group of experienced programmers (10+ years each, but new to C), and after I explained the char

  **av
stuff, one of them said "Now it is overhead transmission" :)
Re:C Primer by Vindicis on Friday May 04, 2018 @02:44PM (#16997150)
I don't think really anyone has difficulty understanding the concept of a pointer. It's their usage that trips people up, and that most tutorials I've seen gloss over, which is where all the confusion stems from.
Re:C Primer by ovao on Friday May 04, 2018 @09:53PM (#16999865)
Exactly. There is the concept and the syntax of pointers, and those are relatively straightforward to understand. I gave up on learning C++ — twice — when I was a kid because no book explained why there are pointers. It’s all very “a pointer points to something! Now on to the next chapter.” (The third time was the charm, luckily.)

One simple example showing value semantics would’ve made it click for me, and things only get more interesting when you talk about performance.

Re:C Primer by erobbins on Friday May 04, 2018 @04:11PM (#16997874)
I had the same problem.. I kind of flopped and floundered around for a week or 2 before it just suddenly clicked one day and I was off to the races. Pointers are still my favorite part of C, but I struggle to explain them to new programmers.
Re:C Primer by ipython on Wednesday May 09, 2018 @01:18PM (#17031694)
Old school now, but back in the late 90s I used GNU ddd. See some example screenshots here: https://www.gnu.org/software/ddd/manual/html_mono/ddd.html#S...
Re:C Primer by nebgnahz on Friday May 04, 2018 @11:19AM (#16995216)
I have used C Tutor when I was teaching C to undergrad.

Here is a visualization I created to illustrate linked list: https://goo.gl/12juwA

Re:C Primer by scandox on Friday May 04, 2018 @11:29AM (#16995310)
Hey! I actually did see this before because I was searching for exactly that. I think I found it helpful in a specific way - maybe I should try using it for longer to see if it sticks in my mind. I think that's what I'm really lacking - a kind of mental visual short hand that holds together in my head.
Re:C Primer by Gibbon1 on Friday May 04, 2018 @04:02PM (#16997796)
> what I always wanted was a great visualization system for pointers

Look at 68000 assembly language. In particular indexed addressing modes.

In C really that's almost all they are.

Re:C Primer by groundCode on Friday May 04, 2018 @10:10AM (#16994707)
David malan’s CS50 course has some nice material on this. Some of the clearest well presented and enthusiastic lectures I’ve seen.
Re:C Primer by mcjiggerlog on Friday May 04, 2018 @11:14AM (#16995176)
Where can we watch them?
Re:C Primer by b3b0p on Friday May 04, 2018 @12:02PM (#16995617)
There are multiple websites and communities. The /r/cs50 [0] is popular. Also, there is cs50.tv [1]. Tons of information and where or how to work through the course. Many options.

[0] https://reddit.com/r/cs50

[1] https://cs50.tv

Re:C Primer by sus_007 on Friday May 04, 2018 @11:32AM (#16995331)
Re:C Primer by mcjiggerlog on Friday May 04, 2018 @11:36AM (#16995378)
As far as I can tell, only the last lecture is available.
Re:C Primer by philangist on Friday May 04, 2018 @11:57AM (#16995558)