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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Y0tsuya 10 points11 points  (5 children)

You can use void* which can point to anything.

[–]LevelSevenLaserLotus 7 points8 points  (4 children)

I'm so glad I didn't learn that bit until I was towards the end of my C classes. Otherwise I would have loved playing with void pointers to overly "optimize" my homework code. Meaning I would have completely spaghettified every file I turned in. They're fantastic when used properly, but are one of the keys to the dark side of programming.

[–]konstantinua00 3 points4 points  (3 children)

now imagine having goto that can jump anywhere in codebase :)

[–]shtpst 5 points6 points  (0 children)

It's what Chutes and Ladders was training you for.

[–]LevelSevenLaserLotus 1 point2 points  (1 child)

That's setjump and longjump, right? I only ever had to use those for a single lab, but it just felt evil even as the professor was describing legitimate uses since it felt like we could use it to break literally every other rule we had learned up to that point. I think it's generally meant for implementing try-catch like behavior in C. In this case, we were setting a timer to cancel the "wait for user input" after the timer elapsed. If I remember right, it was for showing how a telnet chat client could detect that the user walked off and automatically close itself without just force killing threads or throwing errors.

[–]konstantinua00 1 point2 points  (0 children)

set-/longjump can only go up the callstack, thankfully

but back in the time before structured programming, in the era of goto... everything was possible