3 ms·
Not a C programmer , but if I was asked to implement this I would be more comfortable doing something like the first. The second took me a few moments to figure
by jiggy2011 14y ago
Not a C programmer , but if I was asked to implement this I would be more comfortable doing something like the first. The second took me a few moments to figure out.
Perhaps this is a result of many people learning in languages like Java where the idea of double indirection isn't quite so explicit so this style feels somewhat unnatural?
I could easily imagine introducing very weird bugs by mixing up my pointers and pointers-to-pointers. To mentally visualise a linked list I find it easier to just imagine a stack of boxes attached by string and work on the basis of cutting and reattaching the string to different points, this is more difficult under the 2nd approach.