Last active
July 23, 2018 08:47
-
-
Save minhducsun2002/febc0c0ab5ed833d19e925bbaa1c19c9 to your computer and use it in GitHub Desktop.
C++ template for I/O from file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#ifdef ENG | |
string filename = "hash2"; | |
string input_ext = "inp", output_ext = "out", debug_ext = "debugging"; | |
string input_filename = filename + '.' + input_ext, | |
output_filename = filename + '.' + output_ext, | |
debug_filename = filename + '.' + debug_ext; | |
#endif | |
main() | |
{ | |
#ifdef ENG | |
cerr << "Input file :: " << input_filename << endl; | |
cerr << "Output file :: " << output_filename << endl; | |
cerr << "Debugging file (stderr) :: " << debug_filename << endl; | |
if (freopen (input_filename.c_str(), "r", stdin) == nullptr) | |
return cerr << "No input files found, creating empty input file\n", | |
freopen (input_filename.c_str(), "w", stdout), 0; | |
freopen (output_filename.c_str(), "w", stdout); | |
freopen (debug_filename.c_str(), "w", stderr); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment