IF-THEN's blog

By IF-THEN, history, 4 years ago, In English

What doe the following code mean ? Why use it ?

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
  • Vote: I like it
  • -11
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I understand that It may be a bit annoying for many to answer this question so they will ignore it. What I don't understand is the reasons why some idiots are downvoting.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    https://www.youtube.com/watch?v=Fql_b-xZYwQ

    See this video.... This is a setup used by many Competitive programmers. So, This code helps you to take input from this input file and show the output in the output file. And if the code is being run on any online judge like codeforces, then it won't read the input from the input files.

    Hope, I answered you just fine.

»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

This means that if your _DEBUG is defined then you can read the input from input.txt file (instead of manually typing input every time you compile).