Code stopped working while debugging..

I just came across code for offline debugging, but as i added it in a solution code my solution code stopped working.

Debugging code:

  #ifndef ONLINE_JUDGE
 freopen("", "r" , stdin);
 freopen("a.out", "w", stdout);

I implemented ifndef (debugging) for first time pelase guide me…!!

Code link:

Code is of problem CAPPLE from December challenge but solution do not have bugs but i think so the way i am implementing debugging code is not correct.!! Still if one want to visit problem so problem link is: .

Please guide me to a proper way for using the offline debugging method…

Please help…!

This is because that the judge does not contains “” file.So just change to these :

freopen(fi, “r” , stdin);

freopen(fo, “w”, stdout);

But in your PC, if “” file is present then it’s perfectly fine to use your approach.In this case, the output is written to “a.out” file.Check out this :
Also look at this :

1 Like

but i am using a file named which is stored in the same directory where the solution code is saved

Also i want to tell you if i paste debugging code in another program then it works… :frowning: but i am not getting why is it not working for this code…

I didn’t get you, can you please give the link for the code which works.

It works perfectly fine or me.I mean(“”,“source code” are present in same directory, when I executed it output is written to “a.out”).

okay let me check it again, dont know why that didn’t worked…!! :frowning:

Bro i am feeling embarrassed…!!

Sorry i was putting file in wrong directory…!! thanks…

But for general case will using fi and fo work? mean that i dont know the name of input/output file so i should use fi and fo…?

And really sorry for wasting your time… :frowning: