Sublime Forum

Sublime Text isn't showing correct output of C++ program

#1

Hey Everyone,
I need a help, actually I’m using Sublime text 3 for competitive programming for a long time and for me, it’s the best code editor ever.
I use C++ language for coding. Suddenly it started showing some irrelevant values in output file.

#ifndef ONLINE_JUDGE
freopen("inputf.in", "r", stdin);
freopen("outputf.in", "w", stdout);
#endif

As we know, we use the above code while coding in editor in our local machine( for C++). previously I didn’t used that code yet my all programs ran perfectly.
Since the problem occurred it started showing something like, even it’s a hello world program.

Code Sample
#include< iostream>
using namespace std;
int main()
{
cout<<“Hello, world”;
return 0;
}
Output
4865 6c6c 6f2c 2077 6f72 6c64

As of now if I include the following stuff,

#ifndef ONLINE_JUDGE
freopen(“inputf.in”, “r”, stdin);
freopen(“outputf.in”, “w”, stdout);
#endif

in main function, then it stops showing the output now.
It’s a great problem for me since this I’m unable to code. I searched on Google yet I couldn’t get any solution. so I’m depend on the community please help asap.

0 Likes

#2

Those lines will make the problem use the inputf.in and outputf.in files for input and output. You won’t see output in the console because you’re redirecting it to a file.

0 Likes

#3

May you please elaborate more, what exactly should I write?
I couldn’t understand that much, please :pray:

0 Likes

#4

Those lines of code are sending the output to a file called outputf.in instead of the console.

0 Likes

#5

Hey i am facing the same issue aswell, did you resolve it?

0 Likes