Programming has a lot in common with playing chess or solving sodoku. You must think ahead and must try to anticipate which concepts could cause trouble. Even if some code snippet is clear and clean in itself and works like a charm, it could turn into bad code when combined or inbedded in a superscript. You might become mad over thousands of errors you have to solve. However, the reason of almost all errors still is logical and reasonable. With this in mind you take care of your possible errors before you do them by developing and applying nice and safe concepts often at the cost of memory usage.
Ah gotta love working with C++ and Allegro; with an Allegro library error, it simply wont TELL you there is one, it just crashes! It isn't too bad, one of the key skills with being a programmer is problem solving. Always comment, remember to that trace statements can help you track errors, modulate your program, make it neat and readable, avoid smell code, and most importantly test your program with each little thing you do! Never do a thousand things before you test!