errno
#include <errno.h>
#include <iostream>
int main() {
FILE* file = fopen("myfile.txt", "r");
if (file == NULL) {
std::cerr << "Error opening file: " << strerror(errno) << "\n";
return EXIT_FAILURE;
}
// File opened successfully, perform operations...
fclose(file);
return EXIT_SUCCESS;
}#include <errno.h>
#include <iostream>
int main() {
int status = system("ls -l");
if (status == -1) {
std::cerr << "Error executing system call: " << strerror(errno) << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}