解析errno
#include <fstream>
#include <memory>
#include <stdio.h>
#include <thread>
#include <iostream>
int main()
{
int file_size = 1024 * 1024 * 100;
try {
std::ifstream ifs("./1.txt");
ifs.exceptions(std::ios::failbit);
while (1)
{
new uint8_t[file_size];
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::cout << "malloc memory once " << std::endl;
}
}
catch (std::exception& e)
{
printf("std::exception orrcu, error is : %s \n", e.what());
}
catch (...)
{
printf("unknown exception orrcu \n");
}
perror("error occur");
return 0;
}