# \#ifndef ONLINE\_JUDGE ?

**URL:** <https://discuss.codechef.com/t/ifndef-online_judge/17162>\
**Category:** general\
**Tags:** c-plus-plus-14, online\_judge\
**Created:** [October 23, 2017, 1:50pm UTC](https://discuss.codechef.com/t/ifndef-online_judge/17162 "2017-10-23T13:50:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jagreetdg](https://discuss.codechef.com/user_avatar/discuss.codechef.com/jagreetdg/32/129665_2.png) [@jagreetdg](https://discuss.codechef.com/u/jagreetdg)\
**Post date:** [October 23, 2017, 2:09pm UTC](https://discuss.codechef.com/t/ifndef-online_judge/17162/2 "2017-10-23T14:09:06Z")

</div>

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](https://m.youtube.com/watch?v=DlPTG4AkuqU)

---

_[View the full topic](https://discuss.codechef.com/t/ifndef-online_judge/17162)._
