# Pastebin nZQNcepJ #include #include #include int main() { FILE *fp = fopen("./file.txt", "r"); if (!fp) { switch (errno) { case ENOENT: { perror("File not found"); fp = fopen("./file.txt", "w"); if (!fp) { perror("Failed to create file"); return EXIT_FAILURE; } /* write default file contents here */ break; } default: perror("Failed to open file"); return EXIT_FAILURE; } } /* read existing config here */ return EXIT_SUCCESS; }