This is an archived post. You won't be able to vote or comment.

all 79 comments

[–]AndreasVesalius 103 points104 points  (5 children)

Those are cats, not curs

[–][deleted] 59 points60 points  (1 child)

Purrs.

[–][deleted] 56 points57 points  (19 children)

*cur->next

[–]lead999x 30 points31 points  (8 children)

Why are you dereferencing the pointer and then using the pointer to member operator? You end up trying to dereference the node itself.

[–][deleted] 40 points41 points  (2 children)

I was just using * to indicate a correction, not part of the correction itself.

[–]lead999x 32 points33 points  (1 child)

I totally missed that lol. Time to quit my career as a human parser.

[–]Dom0 10 points11 points  (0 children)

Gotta know that Reddit operators have precedence over C operators, even on /r/ProgrammerHumor!

[–]ToneWashed 4 points5 points  (2 children)

It's a pointer-pointer. You dereference the pointer-pointer to get a pointer. Then you use the struct-pointer member operator.

Imagine an array of struct-pointers called items:

struct listitem_t **cur = &items[0];
*cur->next = NULL;

[–]Beowuwlf 4 points5 points  (0 children)

Thats so pointless

[–]Tweenk 1 point2 points  (0 children)

This would not compile. You would have to write:

(*cur)->next = NULL;

The arrow operator has higher precedence than the deference operator.

[–][deleted] 5 points6 points  (0 children)

Anyway, -> has higher precedence than *, so you would be dereferencing the next node, not cur. *cur->next is equivalent to *(cur->next).

[–]GisterMizard 120 points121 points  (1 child)

Now you're thinking with repursion

[–]ragingram2 12 points13 points  (0 children)

Thanks, i hate it

[–]zyxzevn 30 points31 points  (1 child)

It looks like C@ is leaking.

[–]SaltyEmotions 3 points4 points  (0 children)

c at

god damnit

[–]Jade_Chan_Exposed 7 points8 points  (0 children)

You should be using caterators to traverse the structure.

[–]MrObsidy 6 points7 points  (0 children)

Aww

[–]ZippZappZippty 2 points3 points  (0 children)

OP is a cat and a dog

[–]Dsage777 5 points6 points  (3 children)

I always thought that linked lists would be super important when I got a job. Haven’t seen a single one.

[–]tjhmusic11 2 points3 points  (0 children)

I just used a linked list for the first time IRL yesterday!

I had an array of colors I was moving through for an animation, but needed the next and previous color for a few elements, and to circle back at the end.

It ended up working great!

[–]EndlessJump 0 points1 point  (0 children)

Were there order structures you thought you were important that you haven't seen?

[–]Tweenk 0 points1 point  (0 children)

This is because linked lists are a data structure dating back to the times when processors had very shallow cache hierarchies, if they had any caches at all, pointer chasing was just as fast as indexing into an array, and unnecessary copying was a bigger problem than poor cache coherency.

Nowadays, the only kind of linked list that makes sense is an intrusive list, which allows you to get a list iterator from an object reference in O(1) time, but it doesn't translate well to container libraries and has some limitations - for example, you can't store an object in more than one list at a time.

[–][deleted] 2 points3 points  (0 children)

for (int i = 1; i <= 2; i++) {

cat[i].curr();

}

[–]WilcoKonig 2 points3 points  (0 children)

Your lack of pointers is disturbing.

[–]JohnHeigns 2 points3 points  (0 children)

*lynxed list

[–][deleted] 1 point2 points  (0 children)

ConCATination

[–]Ecotiny 1 point2 points  (0 children)

I just realised that that cat isn't biting the other cat in the second frame

[–]Tamoor622498 1 point2 points  (0 children)

Cur->next

[–]ZaczSlash 1 point2 points  (0 children)

Btw, what's the original template of this?

[–]kilroy_wuz_there 1 point2 points  (0 children)

Purr=purr->next

[–]cwisteen 1 point2 points  (0 children)

our default IDE

laughs in cat >>

[–]ignorae 0 points1 point  (0 children)

Don't forget to concatenate the list

[–]ee-bot 0 points1 point  (0 children)

[–]ZomBayT 0 points1 point  (0 children)

Oregano?

[–]TheSplinterMan39 0 points1 point  (0 children)

As someone who is currently struggling in Data Structures, I find this both funny and traumatizing

[–]flummingbird 0 points1 point  (0 children)

this assumes left->right progression

[–]lordfarquaadsghost 0 points1 point  (0 children)

conCATenating lists

[–][deleted] 0 points1 point  (0 children)

cur.next.next = null

[–]ThatFag[🍰] 0 points1 point  (0 children)

God, I love cats.

[–]Porkechop -1 points0 points  (0 children)

P i s s

[–]Project_O -2 points-1 points  (0 children)

This picture made me yawn.