I, I guess that your problem is that you are using %i for the angles[0] variable while angles is an array of floating point numbers. This should give you some weird values.
Try changing the fourth %i to %f
edit:
also, note that angles[0] is pitch, angles[1] is yaw and angles[2] is roll. I think at least.
This shows which is which I guess:
http://www.dform.com/gif/dirhead.gif
__________________