1

Sublime text is my favourite text editor. That's why I want to make this as full C or C++ IDE. I have already downloaded MinGW compiler. Using that I can compile and run my program. But I am facing problems in taking input from sublime text console.

Is it possible to use scanf or cin function in Sublime text ??

If possible, please suggest me the exact way. If not possible, please suggest me a good IDE or text editor like sublime text by which I can easily run C or C++ program.

N:B: Don't suggest me of using codeblocks.

Take thanks in advance.

Depta Paul
  • 11
  • 1
  • 4
  • You are basically asking two things here; and that second part (asking for recommendations is off-topic). For that, turn to https://softwarerecs.stackexchange.com/ instead – GhostCat May 18 '17 at 19:12
  • That means you are trying to say that 1st part is not possible ?? – Depta Paul May 19 '17 at 01:12
  • If I could say something about part one, I would have done so :-( – GhostCat May 19 '17 at 02:53
  • 1
    Possible duplicate of [Sublime Text 2 console input](http://stackoverflow.com/questions/10604409/sublime-text-2-console-input) – Keith Hall May 19 '17 at 07:57
  • 1
    No, this is not duplicate.... Please read the description carefully. In short, I want to tell you that, I am using C or C++ language. – Depta Paul May 19 '17 at 14:11
  • @GhostCat I know that 1st part is possible ... So there is no chance of 2nd part. Please read the description again carefully. I mentioned (if not possible)... But I know that it is possible(1st part). I want to know the exact steps. – Depta Paul May 19 '17 at 14:16
  • Does this answer your question? [How to compile and run C in sublime text 3?](https://stackoverflow.com/questions/24225343/how-to-compile-and-run-c-in-sublime-text-3) – Miraz Jun 17 '21 at 17:04

1 Answers1

2

As mentioned before REPL is a good solution. Another simple workaround is running the program in a new console window. Here's how my build system for running C++ programs on Windows looks like:

{
  "shell_cmd": "g++ -Wall \"${file}\" -o \"${file_path}/${file_base_name}\"",
  "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  "working_dir": "${file_path}",
  "selector": "source.cpp, source.c++",

  "variants":
  [
    { 
      "name": "New window",
      "shell_cmd": "start cmd.exe @cmd /k \"@g++ -Wall \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\" & @pause & exit\""
    }
  ]
}

You can save it into your sublime user packages catalog with extension .sublime-build.

zamkot
  • 81
  • 7