INPUT doesn't match C declaration and probably has wrong size. Also to properly handle errors first check return code and then last error.