You’ve learned a lot about C. You’ve learned about arrays, pointers, dynamically allocating memory, and accessing files. Along the way, we’ve hinted at some of the pitfalls you have to look out for: not storing values outside the dimension of an array, not using uninitialized pointers, checking
EOF, and so on. But we haven’t really been doing this in any systematic way.
Error handling is a general term for writing code so it still works when unexpected things happens. And believe us, unexpected things will happen. Your code isn’t battling for survival in the inevitable zombie apocalypse, but your program does need to defend itself from erroneous values, unexpected circumstances, and (yes) even hackers. ...