Sublime Text 3 not showing correct output C++

668 Views Asked by At

I am using Sublime Text 3 in Windows 10. I am trying to output a simple program in an output file. Earlier it was working fine, but now it is giving some strange alphanumeric characters as output whenever I am trying to output something.

Here's my build profile:

{
"cmd": ["g++.exe","-std=c++17", "${file}", "-o", "${file_base_name}.exe", "&&" , "${file_base_name}.exe<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}

Sample input

#include <iostream>
using namespace std;
int main() {
    for (int i = 0; i < 10; i++) {
        cout << i << endl;
    }
}

Output:

300d 0a31 0d0a 320d 0a33 0d0a 340d 0a35
0d0a 360d 0a37 0d0a 380d 0a39 0d0a 
3

There are 3 best solutions below

0
On

It happened with me also; I use C++14 in sublime text 3.

I would suggest to delete your sublime build file and create the same again, and your "inputf.in" and "outputf.in" files should be present in the same folder.

There's a common confusion, as we copy the sublime build file from somewhere and there may be different file names for input and output files, so match them with yours, otherwise you'll get an error - "system can't find file specified".

0
On

You can do one thing

  1. First delete inputf.in, outputf.in and outputf.out files
  2. Now create new inputf.in and outputf.in file in the same folder where you are saving the cpp file

Now try to run the build. It worked for me!

1
On

Same problem i was also facing,after the update. After that i uninstalled the setup and located the folder some where else so that after reinstallation it makes new folder for its packages and all after that i created new inputf.in and outputf.in files for competitive programming and i again used system built file as usual what i used to do and it worked....now it gives proper outputs...