O'Reilly logo

Learn C on the Mac: For OS X and iOS, Second Edition by James Bucanek, David Mark Scott Brown

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter    12

Handling Errors

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 fgetc() for 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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required