#ifndef ONLINE_JUDGE?

What is the use of #ifndef ONLINE_JUDGE

1 Like

It’s used for offline fast input. For example when you are coding a solution on your device you can use
#IFNDEF ONLINE_JUDGE
//take input via filestreams
#ELSE
//take input via stdin

now codechef must compile the program like this:-
g++ filename.cpp -DONLINE_JUDGE
so basically it’s defining online judge environment and those commands inside IFNDEF are never executed or even compiled for that matter.
It’s just a way of quickly doing testcase checking, like the stopwatch macros some people use.

1 Like

yup basically compile time “if else”