#ifndef Online Judge

I was looking into the solution of the submission of those problem which I wasn’t able to solve. I found the following syntax used by many people. Please explain what it does?

#ifndef ONLINE_JUDGE
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);
#endif

Duplicate thread.

it just say’s if online judge is not defined then use input.txt as the file to take input from and output.txt to write the output this is very helpful in term’s of speeding up as you can prepare the set of input’s once and you can use that file as many times as you want you don’t need to enter the input’s again and again…

2 Likes