[update]add error handling, use c11 and c++11