std::string str="1111111111111111111111111111";
std::ofstream file("3.png",std::ios::binary|std::ios::out);
file_.write(str,str.size());
//写入失败时
if(file_.bad())
{
std::cout<<"写入失败\n";
}
// 可能是 D盘没有位置了 没有位置去写入
还有一个可以返回错误码的函数,直接判断因为什么错误
std::string str="1111111111111111111111111111";
std::ofstream file("3.png",std::ios::binary|std::ios::out);
file_.write(str,str.size());
//写入失败时
if(file_.bad())
{
std::cout<<"写入失败\n";
}
// 可能是 D盘没有位置了 没有位置去写入
还有一个可以返回错误码的函数,直接判断因为什么错误