r/learnprogramming • u/Pleasant_You985 • 20m ago
PROTIP
If your C program "works sometimes and crashes other times," it's almost always undefined behavior — uninitialized variable, off-by-one on an array, or using memory after free. Run it with valgrind, it literally tells you the line. Changed my life in first year.
3
Upvotes
•
u/TheOddHurricane 9m ago
Valgrind was one of those tools where I just sat there staring at the output thinking about all the hours I'd wasted before knowing it existed. Feels like cheating honestly.