GOOGLED IT YET COULDNT FIND ANTHING
inline void debugMode() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
inline void debugMode() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
This is a general practice by c++ programmers who code in a text editor rather than an IDE. By default the ONLINE_JUDGE constant is defined when submitting code in most online judges like Codechef and Codeforces. Thus it provides a way for the code to determine whether the code is being run in an online judge or a local machine, where the constant is not defined in the latter. Generally this flag is used in order for the code to read & write from a file rather than stdin when run on a local machine and read & write from stdin and stdout respectively when run in an online judge. Thus it eliminates the need to edit the code, for reading from a file, and again for reading from stdin.
Refer to this video for more details : Setting up Sublime Text for Competitive Coding - YouTube
thanks… finally got it
My pleasure
Thanks a lot! This link was of great help!
Is it helpful in “interactive problems”?
No, you can’t use it for an interactive problem. For interactive problems we’ve to use the inbuilt terminal.
I didn’t get this sentence…i mean here we are pointing stdin to read from input.txt,that means we need to edit the code(commenting the online_judge) for reading from console right?
I put that ifndef part in my c++ code. But after that no output is shown in the output file. What is the problem, I don’t understand
check whether you have called the function or not. debugMode();