C++fy the code: Remove fprintf's and throw exceptions on fail to the initialize input method.

Reviewed by: Thiago Lacerda